0

我有列表视图

 <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>

第一个 TextBlock - Foreground="Black" 第二个 TextBlock - 未指定前景。

在 ListView 中的选定项目中,第一个 TextBlock foreground="Black"(在每个操作系统中出现错误),第二个 TextBlock - 前景默认值(在每个操作系统中正确出现)。

我需要的:

在 ListView 中的选定项目中,第一个 TextBlock 前景也必须是默认的,并且在每个操作系统中都正确显示,但我不能直接更改 TextBlock 前景(在触发器或样式中)。

有什么想法吗?也许我可以重置第一个 TextBlock 的前景(没有设置默认前景!完全重置)。或者将样式重置为默认值??

4

1 回答 1

1

不确定我的问题是否正确,但这是我的猜测:你不能改变Foreground你的第一个TextBlock,因为它是明确设置的。只需从控件本身中删除前景定义并将其设置为样式,这应该使其可以被其他样式和触发器覆盖。

有更多细节的答案(比如这个),所以你的问题有些重复。好吧,如果我做对了 =)

于 2013-02-26T11:27:43.253 回答