Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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# 更改DataGridTemplateColumn内容样式_C#_Css_Wpf - Fatal编程技术网

C# 更改DataGridTemplateColumn内容样式

C# 更改DataGridTemplateColumn内容样式,c#,css,wpf,C#,Css,Wpf,我想更改DataGridTemplateColumn内容样式,下面是DataGridTemplateColumn代码: <DataGridTemplateColumn MaxWidth="50" MinWidth="30" CellStyle="{StaticResource CellStyle}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Label Style

我想更改DataGridTemplateColumn内容样式,下面是DataGridTemplateColumn代码:

<DataGridTemplateColumn MaxWidth="50" MinWidth="30" CellStyle="{StaticResource CellStyle}">
<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <Label Style="{StaticResource FontAwesome}" Padding="0" VerticalAlignment="Center" HorizontalAlignment="Center" Cursor="Hand" MouseLeftButtonDown="LblEdit_MouseLeftButtonDown">
            
        </Label>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
以下是CellStype代码:

<Style x:Key="CellStyle" TargetType="DataGridCell">
    <Setter Property="BorderThickness" Value="0 0 1 0"/>
    <Setter Property="BorderBrush" Value="#F6F6F6"/>
    <Setter Property="Foreground" Value="#000"/>
    <Setter Property="FontSize" Value="14" />
    <Style.Triggers>
        <Trigger Property="DataGridCell.IsSelected" Value="True">
            <Setter Property="Background" Value="#FF5750" />
            <Setter Property="Foreground" Value="#FFFFFF" />
        </Trigger>
    </Style.Triggers>
</Style>

但DataTemplate中的标签在选择行时无效,而其他单元格无效

有办法吗


谢谢

触发器设置
DataGridCell
的前景色,但不设置
标签的前景色。通过将此
前景
属性添加到标签中,可以在标签中引用前景颜色:

<Label 
    Style="{StaticResource FontAwesome}" 
    Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Control}, Path=Foreground}"
    ... />