xmlns?
While reviewing Blendables and NetAdvantage products, I noticed that including them in XAML required something like this
So I started wondering how to map .NET namespaces to xmlns...
The answer is pretty simple, open your libraries AssemblyInfo.cs (For those of you who also didn't know where to find it, have a look under Properties in your solution explorer) and add the following:
[assembly: XmlnsDefinition("http://StockWATCH.co.za/Controls", "StockWatch.Controls")] |
This basically maps my namespace StockWatch.Controls to a easier to use xmlns called http://StockWATCH.co.za/Controls!
The beauty of this approach is that you can map multiple .NET namespaces to one xmlns (Many-to-one)!
Every wondered what happens under the hood if your XAML declares the following by default?
Well, this is all the .NET namespaces included:
- System.Windows
- System.Windows.Automation
- System.Windows.Controls
- System.Windows.Controls.Primitives
- System.Windows.Data
- System.Windows.Documents
- System.Windows.Forms.Integration
- System.Windows.Ink
- System.Windows.Input
- System.Windows.Media
- System.Windows.Media.Animation
- System.Windows.Media.Effects
- System.Windows.Media.Imaging
- System.Windows.Media.Media3D
- System.Windows.Media.TextFormatting
- System.Windows.Navigation
- System.Windows.Shapes