Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当IsEnabled设置为False时,如何为DataGridRow应用非默认前景色?_C#_Wpf_Xaml - Fatal编程技术网

C# 当IsEnabled设置为False时,如何为DataGridRow应用非默认前景色?

C# 当IsEnabled设置为False时,如何为DataGridRow应用非默认前景色?,c#,wpf,xaml,C#,Wpf,Xaml,当IsEnabled设置为False时,如何为DataGridRow应用非默认前景色? 我是这样做的,但前景色没有改变 <DataGrid.RowStyle> <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> <Style.Triggers> <DataTrigger Bindin

当IsEnabled设置为False时,如何为DataGridRow应用非默认前景色? 我是这样做的,但前景色没有改变

<DataGrid.RowStyle>
      <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
           <Style.Triggers>
               <DataTrigger Binding="{Binding Name, Converter={StaticResource Converterz}}" Value="true">
                  <Setter Property="IsEnabled" Value="False"/>
                  <Setter Property="Foreground" Value="Black"></Setter>
               </DataTrigger>        
           </Style.Triggers>
       </Style>
</DataGrid.RowStyle>

编辑1

好的,我为DataGrid.CellStyle而不是DataGrid.RowStyle应用了样式,它工作了,但只适用于带有TextBlock的单元格。谁能告诉我为什么

<DataGrid.CellStyle>
       <Style TargetType="{x:Type DataGridCell}" >
           <Style.Triggers>
              <DataTrigger Binding="{Binding Name, Converter={StaticResource Converterz}}" Value="true">
                 <Setter Property="IsEnabled" Value="False"/>
                                </DataTrigger>
              <Trigger Property="IsEnabled" Value="False">
                 <Setter Property="Foreground" Value="Black"/>
                 <Setter Property="FontWeight" Value="Bold"/>
              </Trigger>
           </Style.Triggers>
       </Style>
 </DataGrid.CellStyle>