将自定义类映射到单个ResourceDictionary [英] Mapping custom class to individual ResourceDictionary
问题描述
我想在ResourceDictionary中定义listboxitem的DataTemplate.映射时出现错误.
课是:
I want to define a DataTemplate of listboxitem in a ResourceDictionary. when mapping I got error.
class is:
namespace DictMainUI.Model
{
public class SearchListItem:INotifyPropertyChanged
{
.............
}}
Mainwindow的命名空间是DictMainUI,但我的自定义类的命名空间是DictMainUI.Model
在ResourceDictionary中,添加最后一行时显示错误,否则可以.在整个解决方案中,只有一个项目,因此代码为:
the Mainwindow ''s namespace is DictMainUI, but namespace of my custome class is DictMainUI.Model
in ResourceDictionary, when add the last line it shows error, otherwise it is ok. in whole solution there is only one project, so code is:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:DictMainUI.Model"
>
我看到了许多有关映射的文章,但找不到解决方案.
请帮助我,有人知道该怎么做吗?
I saw many articles about mapping, but I could not find solution.
please help me , is there anyone know what to do?
推荐答案
看起来问题出在项目上,但我并不知道.自从我创建了一个全新的项目并尝试将custome类映射到resourcedictionary之后,它就起作用了.我不知道为什么,但是有效.
looks like the problem is with the project, but I do not know excatly. since I created a whole new project and tried mapping custome class to resourcedictionary and it worked. I don''t why , but it worked.
这篇关于将自定义类映射到单个ResourceDictionary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!