我已经实现了一个转换器,将 Int32 转换为 String,以便能够将属性绑定到文本框。
我在命名空间 MyApp.Converters 中实现了这个转换器,它被称为 Int32ToStringConverter。
然后,在我的 axml 中添加对转换器的引用,如下所示:
<Window x:Class="MusicaDB.Views.PrincipalView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
**xmlns:converter="clr-namesapce:MyApp.Converters, aseembly=MyApp**">
后来,在 windows.Resources 中我有:
<Window.Resources>
<**converter:Int32ToStringConverter** x:Key="Int32ToStringConverter" />
</Window.Resources>
我收到错误消息,命名空间 MyApp.Converters, assembly=MyApp 中不存在标记 Int32ToString 转换器。
我的项目位于本地硬盘中,在项目属性中,目标 .NET 是框架 4.0,而不是框架 4.0 客户端配置文件,我尝试清除解决方案并重新编译,但问题仍然存在。
主要是,这是我总是找到的两个解决方案,但不能解决我的问题。
这里需要进行三个修复:
- 没有空格 ->
xmlns:converter="clr-namesapce:MyApp.Converters,aseembly=MyApp"
- 没有拼写错误 ->
xmlns:converter="clr-namespace:MyApp.Converters,assembly=MyApp"
- 右分隔符 ->
xmlns:converter="clr-namespace:MyApp.Converters;assembly=MyApp"
来自文档 http://msdn.microsoft.com/en-us/library/ms747086.aspx:
请注意,分隔符clr 命名空间标记与其值是冒号 (:),而分隔标记的字符assembly从其值来看,token 是一个等号 (=)。这两个标记之间使用的字符是分号。另外,请勿在声明中的任何位置包含任何空格。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)