Wednesday, October 19, 2016

Why are there two formats to the WpfToolkit namespace?

Why are there two formats to the WpfToolkit namespace?

        xmlns:toolkit1="http://schemas.microsoft.com/wpf/2008/toolkit"
        xmlns:toolkit2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"

Well, they are slightly different.

The frst example you provided allows for a namespace declaration to map to multiple CLR namespaces. For example, System.Windows and System.Windows.Controls maps to the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace, allowing you to reference any controls from either mapped CLR namespace from a single declaration.

The second example is a fully qualified namespace declaration. It only maps to a single CLR namespace and you will only have access to controls in that single CLR namespace.

For more information on namespaces please visit this link: http://msdn.microsoft.com/en-us/library/ms747086.aspx

WpfToolkit/WpfToolkit/AssemblyAttrs.cs:

[assembly:XmlnsDefinition("http://schemas.microsoft.com/wpf/2008/toolkit", "Microsoft.Windows.Controls")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/wpf/2008/toolkit", "Microsoft.Windows.Controls.Primitives")]

Reference:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/4d136742-9850-4747-a7d0-3c21154fa12d/why-are-there-two-formats-to-the-wpftoolkit-namespace-when-should-i-use-each?forum=wpf

https://github.com/dotnetprojects/WpfToolkit/blob/3f638d3d738f3404ccd5fd6ee936cfa6653f1ddc/WpfToolkit/AssemblyAttrs.cs

No comments: