请原谅菜鸟的问题,但我正在兜圈子,需要答案......
无论如何,我一直在看这篇文章WPF: How to bind RadioButtons to an enum? 但我只是无法在 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>
...
我有一个单独的文件保存 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>
...
任何帮助将不胜感激。