【发布时间】:2015-10-04 13:45:27
【问题描述】:
我想创建一个面板,我可以像下面的示例一样使用它。
示例 1:
<custom:CustomPanel ItemsSource="{Binding DataSource}">
<custom:CustomPanel.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</custom:CustomPanel.ItemTemplate>
</custom:CustomPanel>
示例 2:
<custom:CustomPanel>
<TextBlock Text="text1" />
<TextBlock Text="text2" />
<TextBlock Text="text3" />
</custom:CustomPanel>
我实现了第一个,现在我可以正常使用它了。我通过从 ItemsControl 继承有关类来提供它,如下所示。
class CustomPanel : ItemsControl{
...
}
我如何提供第二个示例工作?
【问题讨论】:
-
当您从 ItemsControl 派生时,第二个示例也可以开箱即用。
标签: c# xaml winrt-xaml custom-controls itemscontrol