我正在尝试在xaml中设置一个wpf数据网格,使其看起来像这个图像.那可能吗?我尝试了很多东西,但我仍然有以下问题:
我很感激四个人的帮助.如果有帮助我明天可以在这里发布几次尝试.
编辑:这是生成数据网格的代码,您可以看到我在datagrid.cellstyle中尝试了背景和边距值,但是它导致了上述问题:
<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"/>
<!--<Setter Property="Margin" Value="5,5,5,5"/> -->
<!-- <Setter Property="Background" Value="White"/> -->
</Style>
</DataGrid.CellStyle>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)