正确显示任何操作系统(WPF)的选定元素
本文关键字:元素 WPF 显示 任何 操作系统 | 更新日期: 2023-09-27 18:01:04
我有ListView
<ListView x:Name="listView">
<ListView.View>
<GridView>
<GridViewColumn Width="800" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Display}" Foreground="Black" >
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="800" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Display}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
第一个文本块-前景="黑色"第二个文本块-未指定前景。
在ListView中的选定项目中,第一个TextBlock foreground="Black"
(在每个操作系统中都不正确显示(,第二个TextBlock-前台默认值(在每个OS中都正确显示(。
我需要什么:
在ListView中的选定项目中,第一个TextBlock前台也必须是默认的,并且在每个操作系统中都能正确显示,但我不能直接更改TextBlock前台(以触发器或样式(。
你知道吗?可能我可以重置第一个文本块的前景(没有设置默认前景!完全重置(。或者将样式重置为默认样式??
不确定我是否答对了你的问题,但我的猜测是:你不能更改第一个TextBlock
的Foreground
,因为它是显式设置的。只需从控件本身移除前台定义并将其设置为样式即可,这将使其可被其他样式和触发器覆盖。
有更多细节的答案(比如这个(,所以你的问题有点重复。好吧,如果我做对了=(