目前,我有两个非常大的DataTemplate对象,用于在两个ListBox中显示两组项目。这些DataTemplates在两个样式中的ContentTemplate属性中引用,在两个ListBox的ItemContainerStyle属性中设置。这些项目是相同类型的,DataTemplates除了以下控件外都是相同的:
来自DataTemplate1
<TextBlock Style="{StaticResource TextStyle}" FontSize="20" Foreground="White"
HorizontalAlignment="Left" Panel.ZIndex="2" Text="{Binding RemainingTime.TotalHours,
Converter={StaticResource DoubleToIntegerConverter}, StringFormat={}{0:#00}}" />
From DataTemplate2
<TextBlock Style="{StaticResource TextStyle}" FontSize="20" Foreground="White"
HorizontalAlignment="Left" Panel.ZIndex="2" Text="{Binding ElapsedTime.TotalHours,
Converter={StaticResource DoubleToIntegerConverter}, StringFormat={}{0:#00}}" />
有没有什么方法可以避免复制整个DataTemplate,但仍然在第二个模板中具有此TextBlock的文本绑定中的一个差异?