こんにちは、スタイルを作成して DataGrid ヘッダーに適用しようとすると、次の問題が発生し、次のエラーが発生します。
DependencyProperty.UnsetValue} ' は、プロパティ ' ColumnHeaderStyle ' の有効な値ではありません。"
彼はこれがそうであることに気付きませんでした。誰かが私にアイデアを与えることができれば、グリッドのコードとスタイルを残していただければ幸いです。-
<!-- ************** DATAGRID ************ -->
<Style x:Key="DataGridFloatingWindow" TargetType="{x:Type DataGrid}">
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="CanUserAddRows" Value="False" />
<Setter Property="CanUserReorderColumns" Value="False" />
<Setter Property="CanUserResizeColumns" Value="False" />
<Setter Property="CanUserResizeRows" Value="False" />
<Setter Property="CanUserSortColumns" Value="False" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="SelectionUnit" Value="FullRow" />
<Setter Property="SelectionMode" Value="Extended" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="#fcfcfc" />
<Setter Property="GridLinesVisibility" Value="Horizontal" />
<Setter Property="VerticalGridLinesBrush" Value="Transparent" />
<!--<Setter Property="HorizontalGridLinesBrush"/>-->
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridHeaderFloatingWindow}" >
<!--<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="3,0" MappingMode="Absolute" SpreadMethod="Repeat">
<GradientStop Offset="0" Color="#dedede"/>
<GradientStop Offset="0.5" Color="#dedede"/>
<GradientStop Offset="0.5" Color="Transparent"/>
<GradientStop Offset="1" Color="Transparent"/>
</LinearGradientBrush>
</Setter.Value>-->
</Setter>
<Setter Property="RowStyle">
<Setter.Value>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="#dcdcdc" />
<Setter Property="BorderThickness" Value="0.50"></Setter>
<Setter Property="BorderBrush" Value="#787676"></Setter>
<Setter Property="Foreground" Value="#6e6e6e"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
<Setter Property="CellStyle">
<Setter.Value>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="FontFamily" Value="{DynamicResource KozukaGothicPro}" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Foreground" Value="#6e6e6e" />
<Setter Property="FontWeight" Value="Medium" />
<Setter Property="Padding" Value="10 5 10 7" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="Background" Value="#dcdcdc" />
<Setter Property="Foreground" Value="#040404"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DataGridHeaderFloatingWindow"
TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="28" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter Margin="6,3,6,3" VerticalAlignment="Center" />
<Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill"
Grid.Column="1" Width="8" Height="6" Fill="Red" Margin="0,0,8,0"
VerticalAlignment="Center" RenderTransformOrigin="0.5,0.4" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="SortDirection" Value="{x:Null}" />
</MultiTrigger.Conditions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="true" />
<Condition Property="SortDirection" Value="{x:Null}" />
</MultiTrigger.Conditions>
</MultiTrigger>
<Trigger Property="SortDirection" Value="Ascending">
<Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
<Setter TargetName="SortArrow" Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="180" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="SortDirection" Value="Descending">
<Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataGrid x:Name="GeographicZones" Style="{DynamicResource DataGridFloatingWindow}" >
<DataGrid.Columns>
<DataGridTemplateColumn >
<DataGridTemplateColumn.Header>
<CheckBox x:Name="CheckBoxSelectAll"></CheckBox>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Source={x:Reference CheckBoxSelectAll}, Path=IsChecked, Mode=OneWay}"></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Button Style="{StaticResource GridEditButtonStyle}" Content="{StaticResource GridEditDetailNormal}"></Button>
<Button Style="{StaticResource GridViewButtonStyle}" Content="{StaticResource GridViewDetailNormal}"></Button>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="{DynamicResource FW_General_Name}" Binding="{Binding Path=Name}" />
<DataGridTextColumn Header="{DynamicResource FW_General_Code}" Binding="{Binding Path=Code}" />
<DataGridTemplateColumn Header="{DynamicResource FW_General_Enabled}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<ContentPresenter Content="{StaticResource GridViewEnabled}" Style="{StaticResource DataGridIconOnEnabled}" />
<ContentPresenter Content="{StaticResource GridViewDisabled}" Style="{StaticResource DataGridIconOnDisabled}" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>