WPF에서 DataGrid
의 셀 스타일을 편집하고 싶습니다.WPF에서 스타일 값을 재정의하는 올바른 방법
<SolidColorBrush x:Key="{x:Static DataGrid.FocusBorderBrushKey}" Color="#FF000000"/>
<Style x:Key="DataGridCellStyle1" TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static DataGrid.FocusBorderBrushKey}}"/>
</Trigger>
</Style.Triggers>
</Style>
하지만 난 단지 원하는 : - 그래서 사용 Expression Blend를 내가 오른쪽으로 이동 개체 및 타임 라인 >> 데이터 그리드 >> 추가 템플릿을 편집 >> 편집 CellStyle >> 여기
무슨 일이 페이지에 표시되는 내용의 복사본을 편집 패딩과 배경을 변경합니다. 대신 그것은 세포 틀을 포함하여 25 줄의 코드를 제공합니다! 제가 누락 된 것이 있습니까? 두 항목 만 변경하려고 할 때 여분의 불필요한 코드를 가져 오지 않고도 이와 같은 항목을 스타일링하는 더 좋은 방법이 있습니까?
최고 기능 다음 HorizontalContentAlignment 속성을 재정의합니다. 플러그인 스타일의 DLL을 사용하지 않고도 작업 할 수있게 도와주었습니다. 감사! –