【发布时间】:2017-08-27 22:17:33
【问题描述】:
我在 App.xaml 中设置了一些样式
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value ="HotPink"/>
</Style>
这种风格适用于普通控件,但不适用于 DataTemplates
<TextBlock Text="Test"></TextBlock> <!-- Works here -->
<ItemsControl ItemsSource="{Binding ViewModel.UniverseGroups}" HorizontalAlignment="Right" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RelativePanel>
<TextBlock Text="{Binding Name}"></TextBlock>
<!-- This text still is black -->
</RelativePanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
有没有办法让全局样式甚至在 DataTemplates 中也能正常工作?
【问题讨论】: