![](/img/trans.png)
[英]How can i serialize a WPF custom control which has a property of type ObservableCollection?
[英]Can I use the Dictionary type as a (persistet) property of a custom server control?
我目前正在开发服务器控件,该控件应通过键/值对列表进行配置,如下所示:
<MyControls:ContentRenderer ID="ContentRenderer1" runat="server">
<MyControls:Placeholders>
<MyControls:Placeholder key="ident1">Some text which replaces {ident1}</MyControls:Placeholder>
<MyControls:Placeholder key="ident2">Some text which replaces {ident2}</MyControls:Placeholder>
</MyControls:Placeholders>
<MyControls:ContentRenderer />
我希望该属性成为字典,以便我可以通过其标识符快速检索占位符映射。 我知道如何使用List <T>类创建一个保留上述标记的属性,但我想拥有一个类似于哈希图的数据结构。
我在msdn上读了很多东西,但是如果您想完全控制控件标记的解析方式,我仍然不知道该怎么做。
我不认为以这种方式支持字典。 但是,完成此操作的方法不是使用List,而是使用基于列表的自定义类,该类还存储键/对象的字典映射。
HTH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.