-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DataGrid centered layout style
- Loading branch information
Showing
4 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<!-- Used for DataGrid.CellStyle --> | ||
<Style | ||
x:Key="CenteredDataGridCellStyle" | ||
BasedOn="{StaticResource DefaultDataGridCellStyle}" | ||
TargetType="{x:Type DataGridCell}"> | ||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type DataGridCell}"> | ||
<Border | ||
x:Name="Border" | ||
MinWidth="45" | ||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | ||
VerticalAlignment="{TemplateBinding VerticalAlignment}" | ||
Background="#01FFFFFF" | ||
BorderThickness="0" | ||
SnapsToDevicePixels="True"> | ||
<ContentPresenter | ||
FrameworkElement.HorizontalAlignment="Center" | ||
FrameworkElement.VerticalAlignment="Center" | ||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<!-- Used for DataGrid.ColumnHeaderStyle --> | ||
<Style | ||
x:Key="CenteredDataGridColumnHeaderStyle" | ||
BasedOn="{StaticResource DefaultDataGridColumnHeaderStyle}" | ||
TargetType="{x:Type DataGridColumnHeader}"> | ||
<Setter Property="ContentTemplate"> | ||
<Setter.Value> | ||
<DataTemplate> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
Text="{TemplateBinding Content}" | ||
TextWrapping="Wrap" /> | ||
</DataTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<!-- Used for DataGridTextColumn.ElementStyle --> | ||
<Style | ||
x:Key="CenteredDataGridTextColumnElementStyle" | ||
BasedOn="{StaticResource {x:Type TextBlock}}" | ||
TargetType="{x:Type TextBlock}"> | ||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | ||
</Style> | ||
|
||
<!-- Used for DataGridTextColumn.EditingElementStyle --> | ||
<Style | ||
x:Key="CenteredDataGridTextColumnEditingElementStyle" | ||
BasedOn="{StaticResource {x:Type TextBox}}" | ||
TargetType="TextBox"> | ||
<Setter Property="MinWidth" Value="80" /> | ||
<Setter Property="VerticalAlignment" Value="Center" /> | ||
<Setter Property="HorizontalAlignment" Value="Center" /> | ||
</Style> | ||
|
||
<!-- Used for DataGridTextColumn.CellStyle --> | ||
<Style | ||
x:Key="CenteredDataGridTextColumnCellStyle" | ||
BasedOn="{StaticResource DefaultDataGridCellStyle}" | ||
TargetType="{x:Type DataGridCell}"> | ||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type DataGridCell}"> | ||
<Border | ||
x:Name="Border" | ||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | ||
VerticalAlignment="{TemplateBinding VerticalAlignment}" | ||
Background="#01FFFFFF" | ||
BorderThickness="0" | ||
SnapsToDevicePixels="True"> | ||
<ContentPresenter | ||
FrameworkElement.HorizontalAlignment="Center" | ||
FrameworkElement.VerticalAlignment="Center" | ||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters