2015-06-30 96 views
2

背景颜色在网格线之间留下很小的空间。我怎样才能使它完全填充?我试图尝试填充/保证金= 0wpf datagrid单元格背景颜色不完全填充

截图:http://s21.postimg.org/xqe4mt4dv/Data_Grid_Cell_Background.png

任何造型专家在那里?

<DataGrid ItemsSource="{Binding}" > 
    <DataGrid.CellStyle> 
     <Style TargetType="DataGridCell"> 
      <Setter Property="Background" Value="Red"/> 
     </Style> 
    </DataGrid.CellStyle> 
    </DataGrid> 


    Data = new Dictionary<int,string>();   
    for (int i = 0; i < 5; i++) 
     Data.Add(i, "Text"); 
    DataContext = Data; 

回答

2

这是一件容易的事。设置BorderThickness0:你想找出为什么事情看他们如何看

<DataGrid ItemsSource="{Binding}" > 
    <DataGrid.CellStyle> 
     <Style TargetType="DataGridCell"> 
      <Setter Property="Background" Value="Red"/> 
      <Setter Property="BorderThickness" Value="0" /> 
     </Style> 
    </DataGrid.CellStyle> 
</DataGrid> 

下一次,给史努比一试。检查控件和面板以及它们的属性(在这种情况下,它可能是Margin,Padding或BorderThickness),以查看XAML需要调整的内容。

+0

这会使选择边框消失,但对于真正的迷恋,您可以在“样式”中为“IsSelected”添加一个“触发器”,并将边框厚度重置为1。 – Tekito

相关问题