简体   繁体   中英

How to make DataGrid transparent?

How to make DataGrid transparent?
I'm trying to use Background of DataGrid itself, but this doesn't seem to work.

UPD I need only background and borders transparent, not everything. Text should be visible.

所以,我的解决方案......使用Background =“Transparent”和RowBackground =“Transparent”

<DataGrid
      Background="Transparent" RowBackground="Transparent">
</DataGrid>

Try this:

Background="Transparent" RowBackground="Transparent"

and

<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>

Have you tried setting the Opacity property to 0.0 ?

A value of 0.0 makes the element completely transparent

这是一个无法识别的功能,但如果将可见性设置为隐藏,则与将元素设置为透明相同。

I'm not sure which background you are trying to change, but you can set any background by overriding the DataGrid's ControlTemplate. Your best bet is probably to copy the default DataGrid ControlTemplate from here and then modify the necessary background to match your needs.

When you inicialize datagrid put this tag GridLinesVisibility with argument None

For example:

<DataGrid GridLinesVisibility="None"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM