C# Corner Q3, 2014 MVPs Announced
Webinar - Introduction to WPF
Delhi Developer’s Day: Learn ASP.Net vNext , HTML5, MVC, Hybrid Apps in Windows and Deferred Object Materialization
New Feature: Mention your friends and followers
Go to all article comments >>
Go to all messages >>
A Code Snippet
An Interview Question
Ask a Question
C, C++, MFC
Printing in C#
Visual Studio 2010
Visual Studio 2012
Visual Studio 2013
Databases & DBA
WCF with C#
Reports using C#
Design & Architecture
Mobile & Embedded
Web Services in C#
Multithreading in C#
Games Programming C#
Windows Forms C#
How do I
Windows Store Apps
Internet & Web
Visual Basic .NET
Visual Studio .NET
Request a new Category
Categories of Sql Commands
Deserialize a nested json in c#
Open PopUp on Button Click Using J ...
How to check if the user exists in ...
Access Model State Property within ...
Difference between Claims-based Au ...
Bulk Copy in SQL server using c#.net
Generating/Updating a Code Behind ...
What is Index Component in SharePo ...
Query Rules In SharePoint 2013
XAML coding best practices
Sep 01, 2010
It is good to follow the certain practices while doing XAML coding.
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.
Squeeze Ball Animation in XAML
My First XAML Application
Adding Images to Resource in WPF
How To Make Sure the Silverlight App Gets Keyboard focus
View Previous Comments >>
Hire Mobile & Web Developer
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
Just Became Windows Insider
SharePoint 2010 Web Part Pages don’t Show the Left Navigation by Default
Changing of SharePoint 2010 Custom Site Icon on Web Part Page
Create File GeoDatabase Without Using Arcgis License
Introduction to Query Processing Component in SharePoint 2013 Search
Diffrent Ways to Implement Dispose Patterns/Methods in Your SharePoint Code
How to extend a content DB for single web application using SHarePoint 2010 UI
Open PopUp on Button Click Using JQUERY
Introduction to Search Administration Component in SharePoint 2013
What is Index Component in SharePoint 2013 Search
CBeyond Cloud Services
TERMS & CONDITIONS
©2014 C# Corner. All contents are copyright of their authors.