0
我想创建一个面板,我将能够像下面的例子一样使用它。自定义面板提供数据模板和非数据模板
例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派生时也可以使用。 – Clemens