2010-01-27 48 views
3

请原谅noob问题,但我转圈圈和需要答案...Noobie WPF命名空间和转换问题

不管怎样,我一直在看这篇文章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类,但上述参考给了我以下错误:

Error 1 The tag 'EnumBooleanConverter' does not exist in XML namespace ' http://schemas.microsoft.com/winfx/2006/xaml/presentation '.

我尝试添加到组件的引用,然后附加标签到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> 
... 

任何帮助将不胜感激。

回答

6

经过多次头部刮擦(以及相当数量的屏幕大喊),我发现了这个问题。

事实证明,标识命名空间不应该有程序集。

我定义它像这样

xmlns:local="clr-namespace:Widget;assembly=Widget" 

...但它应该只是没有像现在这样

xmlns:local="clr-namespace:Widget" 
0

确保EnumBooleanConverter是公开访问的,并且它有一个公共的空构造函数。

+0

我想这可能已经解决了这一问题,但是当我做了rebuildI仍然得到错误。 – TeamWild 2010-01-27 13:48:20