I am trying to create a wpf datagrid in xaml so that it looks like this image . Is it possible? I have tried many things, but I still have the following problems:
- The cell border property affects only selected cells. Otherwise, I only have 1px thin lines that can be colored through VerticalGridLinesBrush
- If I set the background color at the datagrid.cell level, it imposes a selection
- I don't know if rounding of borders at the cell level is possible (also for choice)
I am grateful to four for their help. If this helps, I can post a couple of attempts here tomorrow.
Edit: This is my datagrid generating code, as you can see that I experimented with the background and field values ββin the datagrid.cellstyle file, however this led to the above problems:
<DataGrid x:Name="Grid" Height="305" VerticalAlignment="Top" Width="505" BorderThickness="1"
AutoGenerateColumns="False" SelectionUnit="Cell" HeadersVisibility="None" ItemsSource="{Binding}"
CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False"
IsReadOnly="True" HorizontalAlignment="Left" BorderBrush="White" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled"
ScrollViewer.CanContentScroll="False" MouseLeftButtonUp="ScreenGrid_MouseLeftButtonUp" Margin="10,10,0,0" Background="#FF000000"
VerticalGridLinesBrush="White" HorizontalGridLinesBrush="White" SelectedCellsChanged="ScreenGrid_SelectedCellsChanged" >
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue"></SolidColorBrush>
<Style x:Key="DataGridRowStyleColoured" TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#FF000000" />
</Style>
</DataGrid.Resources>
<DataGrid.RowStyle>
<StaticResource ResourceKey="DataGridRowStyleColoured"/>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
</Style>
</DataGrid.CellStyle>
</DataGrid>
spieb source
share