以下XAML(如下)在资源中定义了一个自定义集合,并尝试用自定义对象填充它;
任何关于我做错了什么的线索都将不胜感激。同时,如果有关于如何深入挖掘WPF对象模型以查看运行时公开的属性的提示,那也将非常有帮助,我可能可以通过这种方式找到答案。
谢谢,
Ryan
<UserControl x:Class="ImageListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="300" Height="300"
xmlns:local="clr-namespace:MyControls" >
<UserControl.Resources>
<local:MyCustomCollection x:Key="MyKey">
<local:MyCustomItem>
</local:MyCustomItem>
</local:MyCustomCollection>
</UserControl.Resources>
</UserControl>
问题是我在“我的自定义集合”设计师中遇到了一个错误:“类型‘MyCustomCollection’不支持直接内容”。我已经尝试按照MSDN的建议设置ContentProperty,但无法确定要设置为什么。我使用的自定义集合对象非常简单,如下所示。我已经尝试了Item、Items和MyCustomItem,但想不出还有什么可以尝试的。
<ContentProperty("WhatGoesHere?")> _
Public Class MyCustomCollection
Inherits ObservableCollection(Of MyCustomItem)
End Class
任何关于我做错了什么的线索都将不胜感激。同时,如果有关于如何深入挖掘WPF对象模型以查看运行时公开的属性的提示,那也将非常有帮助,我可能可以通过这种方式找到答案。
谢谢,
Ryan