Tea*_*ild 3 .net wpf xaml namespaces converter
请原谅noob问题,但我要围成一圈,需要答案......
无论如何,我一直在看这篇文章WPF:如何将RadioButtons绑定到枚举?但我无法在XAML文件中识别转换器.
<Window x:Class="Widget.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
<Window.Resources>
<EnumBooleanConverter x:Key="enumBooleanConverter" />
</Window.Resources>
...
Run Code Online (Sandbox Code Playgroud)
我有一个单独的文件持有EnumBooleanConverter类但上面的引用给我以下错误:
错误1 XML名称空间" http://schemas.microsoft.com/winfx/2006/xaml/presentation " 中不存在标记"EnumBooleanConverter ".
我已经尝试添加对程序集的引用,然后将标记附加到XAML但无济于事.
<Window x:Class="Widget.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:local="clr-namespace:Widget;assembly=Widget"
Title="Widget" Height="366" Width="588" WindowStyle="SingleBorderWindow">
<Window.Resources>
<local:EnumBooleanConverter x:Key="enumBooleanConverter" />
</Window.Resources>
...
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
经过多次头部刮擦(并在屏幕上大量喊叫),我发现了问题所在.
事实证明,识别命名空间不应该有程序集.
我这样定义它
xmlns:local="clr-namespace:Widget;assembly=Widget"
Run Code Online (Sandbox Code Playgroud)
......但它应该是这样的
xmlns:local="clr-namespace:Widget"
Run Code Online (Sandbox Code Playgroud)