In Focus
Delhi Chapter Hands On June 22: Limited Seats Register Now
Kolkata Chapter Developer Day: May 25
C# Corner Delhi Chapter Meet, May-18, 2013 Official Recap
Istanbul Chapter May 2013 2nd Seminar Announced : Learn WinJS, Windows Store, MVC
Email :
Password :
Remember me?
Forgot password
Contribute
An Article
A Blog
A News
A Video
A Link
An Interview Question
Ask a Question
TECHNOLOGIES
.NET 4.5
Current Affairs
Learn .NET
SharePoint 2010
Web Development
.NET Assemblies
Databases & DBA
LightSwitch 2012
SharePoint 2013
Web Services in C#
ADO.NET in C#
Design & Architecture
LINQ
Silverlight with C#
Windows 8
AJAX in C#
Exception Handling C#
Mobile & Embedded
Smart Devices
Windows Azure
Android Programming
Graphics Design
Office 2013
SQL
Windows Controls C#
Articles C#
Hardware
OOP/OOD
SQL Server 2012
Windows Forms C#
ASP.NET Controls in C#
How do I
Operating Systems
Testing
Windows Phone 8
ASP.NET MVC with C#
HTML 5
PHP
TypeScript
Windows Server 2012
ASP.NET Programming
Internet & Web
Products
Visual C#
Windows Store Apps
C# Language
iPhone/iPad
Project Management
Visual Studio .NET
Workflow Foundation in C#
C# Tutorials
Java
Reports using C#
Visual Studio 2010
WPF
C, C++, MFC
Java and .NET
Robotics & Hardware
Visual Studio 2012
XAML
Career Advice
JavaScript, CSS
Security in .NET
WCF with C#
XML
Chapters
JQuery
Request a new Category
|
View All
ANSWERS
BLOGS
VIDEOS
INTERVIEWS
BOOKS
LINKS
NEWS
CHAPTERS
CAREER ADVICE
Making your Web Browser in C#
HTML 5 vs Native Apps
Secure Your Android Application from Hackers
Why to fear Object Oriented Programming approach
Check upcoming B'day in Asp.net
Happy Birthday Destin Joy
Compare strings using StringComparison.Ordin ...
Difference between IEnumerable and IEnumerator
Class vs Structure
Import Email from Gmail in ASP.NET
Blog
XAML coding best practices
Posted by
jaison joy
in
Blogs
|
XAML
on
Sep 01, 2010
It is good to follow the certain practices while doing XAML coding.
Tweet
5239
1
0
Some of the XAML coding best practices mentioned below:
* Don't use unnecessary "xmlns" namespaces in the XAML file. This overburdens the load time of the Silverlight page (If you are using Resharper, you can do this very easily as it will change the color of the unnecessary items to Grey).
* Don't add same namespaces multiple times in a single XAML page. It screws up the XAML code at the time of maintenance and also loads the assembly namespace multiple times causing various memory issues at runtime.
* Use proper name for your "xmlns" namespace prefix. For example: xmlns:commonControls is more meaningful than xmlns:cctrl. This avoids multiple declarations of namespaces.
* Try avoiding "xmlns" namespace prefix name as "local". Instead use "localControls" or "localConverters" etc.
* When adding a control that has no elements inside it, better to close it by self-closing tag "/>" instead of the hard closing tag ()
* Remove all unnecessary resource keys if they are not in use. These increases the memory uses and you may sometime encounter some animation issues due to this. If you need it at later point of time, you are always welcome to add it.
* Don't use extra panels (e.g. Grid, StackPanel, Canvas etc.) unless it is required.
* Always try to use Grid as your panel first and if you require other panels, use them.
* Never try to give a name to all of your controls inside your Silverlight page as it takes unnecessary object creation at the time of load. Name only those elements which you want to use from your code behind and/or from your xaml. If you are using MVVM pattern, you can remove the naming of your controls in almost all the cases.
* Use the Visibility property of the controls instead of the Opacity property to hide the content.
* Use proper formatting of your XAML code. This gives better look of code and also easy to maintain in future.
* Use comments in XAML whenever require.
* Try to use StaticResource instead of DynamicResource as it increases the performance and also it throws exceptions at development time. Hence, easier to identify the root cause.
* Remove unnecessary styles if they are not require at all.
* Try to add your styles in a separate file if you want to share them across your application. If they are specific to a single page then add them in the page resource.
This Feature is Sponsored By
DynamicPDF Merger is a developers dream for interacting with any existing PDF documents. Merge, append, split, form fill, flatten stamp and so much more.
Saving User Settings using Teler..
My First XAML Application
post comment
Good listing Jaison.
Posted by
Mahesh Chand
on
Sep 03, 2010
COMMENT USING
PREMIUM SPONSORS
iPhone, Android & Web Development Services
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
More Blogs from this Blogger
To Check Windows Embedded Standard Installed in Device using WiX
Validations in WPF
XAML coding best practices
Some good MSI information and tools
Top 10 WPF Performance Tips
View All
SPONSORED BY
DynamicPDF ReportWriter Suite
PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Follow @twitterapi
Latest Blogs
Mathematical Symbols in Views
Restricting numeric value in Textbox
Creating Inner Join on Multiple Tables in SQL Server
Bind GridView with MS Access Database Table in ASP.NET
Difference between IEnumerable and IEnumerator
Project Cost Estimation
Basic Aspects of Security and Control
Zoom Image in Different Way in ASP.NET
Gridview with checkbox with check all option
Download SAP Crystal Reports for Visual Studio 2010 - Its Free
View All
Poll
Result
All Polls
What is the best product to build Mobile apps?
What is the best product to build Mobile apps
PhoneGap
Icenium
Xamarin Studio
KendoUI Mobile
JQueryMobile
Native iOS/Android
What is the best product to build Mobile apps
Options
Votes
%
PhoneGap
2
2.74
Icenium
0
0.00
Xamarin Studio
1
1.37
KendoUI Mobile
1
1.37
JQueryMobile
61
83.56
Native iOS/Android
8
10.96
Total
73
100%