【发布时间】:2013-01-30 10:36:11
【问题描述】:
我有一个 ItemsControl,其中除 AType 类型之外的所有项目都应具有相同的视图。我怎么能这样做?
我尝试将object 用作DataType,但这是被禁止的(下面有简化示例):
<ItemsControl>
<ItemsControl.Resources>
<DataTemplate DataType="AType">
<TextBox />
</DataTemplate>
<DataTemplate DataType="System:Object">
<Border>
<TextBlock Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
【问题讨论】:
-
在 Silverlight 中,DataTemplate 没有 DataType 属性。见stackoverflow.com/questions/2400522/…
-
Memoizer,共有5个版本
标签: c# silverlight xaml silverlight-4.0 silverlight-5.0