如何使DataGrid透明?
我尝试使用DataGrid本身的背景,但似乎不起作用。
更新:我只需要将背景和边框设置为透明,文本应该是可见的。
因此,我的解决方案是...同时使用Background="Transparent"和RowBackground="Transparent"
<DataGrid
Background="Transparent" RowBackground="Transparent">
</DataGrid>
试试这个:
Background="Transparent" RowBackground="Transparent"
并且
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="Transparent" />
</Style>
</DataGrid.RowHeaderStyle>
当你初始化datagrid时,请使用GridLinesVisibility
标签并带上参数None
例如:
<DataGrid GridLinesVisibility="None"/>
这是一个未记录的功能,但如果您将可见性设置为隐藏,则与将元素设置为透明相同。
我不确定您想要更改哪个背景,但是您可以通过覆盖DataGrid的ControlTemplate来设置任何背景。您最好的选择可能是从这里复制默认的DataGrid ControlTemplate,然后修改必要的背景以满足您的需求。