我有一个继承IDictionary
命名的类ResourceDictionary
。
此外,我还有另一个属性DictionaryKeyProperty
名为Style
.
被DictionaryKeyProperty
命名为TargetType
。
XAML 文件内容:
<ResourceDictionary
xmlns="clr-namespace:Test;assembly=Test"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Style TargetType="test" />
</ResourceDictionary>
它给出了错误Each dictionary entry must have an associated key.
public class ResourceDictionary : IDictionary, ICollection, IEnumerable, INameScope, ISupportInitialize
{
...
}
[ContentProperty("Setters"), DictionaryKeyProperty("TargetType")]
public class Style : Sealable, INameScope, IQueryAmbient, IResources
{
private Type _TargetType;
[Ambient]
public Type TargetType
{
get { return _TargetType; }
set
{
CheckSealed();
if (value == null)
throw new ArgumentNullException("value");
_TargetType = value;
}
}
......
}
我究竟做错了什么?
我怎么解决这个问题?
PS:我想制作一个包含 WPF 等依赖系统的轻量级框架。