반응형
스타일 설정할때 필요한 몇가지 적어논다. 필요하신 분들은 저런 방식으로 적용 가능함
DataGrid Background 처리할때 등등으로 유용합니다.
<DataGrid Grid.Row="1" x:Name="dgCommand" AutoGenerateColumns="False" IsReadOnly="True"
HorizontalGridLinesBrush="Gray"
VerticalGridLinesBrush="Gray">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGrid}">
<Setter Property="Background" Value="#2d2d30"/>
</Style>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#2d2d30"/>
</Style>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="#2d2d30"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#2d2d30"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Padding" Value="5 0 5 0"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type Button}" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}">
<Setter Property="Background" Value="Black" />
</Style>
<Style x:Key="Content" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Index" Binding="{Binding Index}"
ElementStyle="{StaticResource Content}"
Width="Auto"/>
<DataGridTextColumn Header="Type" Binding="{Binding CommandType}"
ElementStyle="{StaticResource Content}"
Width="Auto"/>
<DataGridTextColumn Header="Storage" Binding="{Binding StorageIndex}"
ElementStyle="{StaticResource Content}"
Width="Auto"/>
<DataGridTextColumn Header="Floor" Binding="{Binding FloorIndex}"
ElementStyle="{StaticResource Content}"
Width="Auto"/>
<DataGridTextColumn Header="Bay" Binding="{Binding BayIndex}"
ElementStyle="{StaticResource Content}"
Width="Auto"/>
<DataGridTextColumn Header="RealWorldTime" Binding="{Binding RealWorldTime}"
ElementStyle="{StaticResource Content}"
Width="*"/>
<DataGridTextColumn Header="SimulateTime" Binding="{Binding SimulateTime}"
ElementStyle="{StaticResource Content}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
반응형
'프로그래밍 > WPF' 카테고리의 다른 글
[WPF] DataGridTemplateColumn 내의 Grid Margin 없애기 (0) | 2021.12.06 |
---|---|
[WPF] canvas 내용을 비트맵 이미지로 저장 (0) | 2021.09.09 |
[WPF] 특정 컨트롤 Size 변경될 시, 값 가지고 오기 (0) | 2021.08.11 |
[WPF] UserControl DependencyProperty 설정과 Binding 방법 (0) | 2021.07.21 |
[WPF] ItemControl에서 Item Index binding (0) | 2021.05.11 |