Лучшая практика, если это возможно, состоит в том, чтобы отделить пространства имен C #, которые вы используете, от пространств имен WPF. Это также уменьшит количество импортируемых вами файлов. Это можно сделать благодаря классу XmlnsDefinition .
<Window x:Class="test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:test="http://whatever.com/test">
В AssemblyInfo.cs ваших библиотек вам просто нужно добавить:
[assembly: XmlnsDefinition("http://whatever.com/test", "test")]
[assembly: XmlnsDefinition("http://whatever.com/test", "test.Converters")]
[assembly: XmlnsDefinition("http://whatever.com/test", "test.Validators")]
[assembly: XmlnsDefinition("http://whatever.com/test", "test.CustomControls")]
Обратите внимание, что это будет работать, только если классы находятся в сборке, отличной от той, на которую вы ссылаетесь. В той же сборке вам все равно нужно будет использовать пространства имен C #.
Вы даже можете полностью исключить импорт, добавив свои пространства имен в пространство имен WPF XML:
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "test")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "test.Converters")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "test.Validators")]
Это позволяет людям писать:
<Window x:Class="test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<!-- Note: no namespace prefix needed! -->
<YourCustomControl />