【发布时间】:2013-07-10 09:24:26
【问题描述】:
老实说,我不确定我在哪里出错了,但无论出于何种原因,下面看到的前景样式都没有应用于数据网格。我对此感到不知所措,因为我真的不知道如何调试 xaml。
<DataGrid Name="dgProperties" Background="#1E918D8D" SelectionMode="Extended" SelectionUnit="FullRow" ItemsSource="{Binding CurFieldData}" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserSortColumns="True" IsReadOnly="True">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" >
<Setter Property="Foreground" Value="#3535bb" />
<!--<Style.Triggers>
<DataTrigger Binding="{Binding Path=DiffState}" Value="Different">
<Setter Property="Foreground" Value="#3535BB" />
</DataTrigger>
</Style.Triggers>-->
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Property" FontSize="12" Binding="{Binding Name}" Width="2*" />
<DataGridTextColumn Header="Left Value" FontSize="12" Binding="{Binding LeftValue}" Width="4*" />
<DataGridTextColumn Header="Right Value" FontSize="12" Binding="{Binding RightValue}" Width="4*"/>
</DataGrid.Columns>
</DataGrid>
您可能可以通过注释掉的触发器来判断,但我最初计划重新着色网格中标记为不同的所有条目(后面代码中的枚举)。但是,这对我不起作用,所以我想尝试看看是否设置了样式,无论触发器如何。
有人看到或知道为什么没有应用这种样式吗?
【问题讨论】:
-
我复制粘贴了您的 Xaml 并应用了一些项目,但文本是蓝色的?所以它似乎正在工作,你确定没有覆盖 Foreground 属性的另一种 dataGrid 样式
标签: wpf xaml data-binding wpfdatagrid