Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Doing it the way you suggest works fine for me, I'll paste the code that I used to test your style. (note that I added background = red so I could actually see if the style was being applied)</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Window.Resources&gt; &lt;Style x:Key="MyDataGridStyle" TargetType="{x:Type DataGrid}"&gt; &lt;Setter Property="Background" Value="Black"/&gt; &lt;Setter Property="CellStyle"&gt; &lt;Setter.Value&gt; &lt;Style TargetType="{x:Type DataGridCell}"&gt; &lt;Setter Property="BorderThickness" Value="0" /&gt; &lt;Setter Property="Background" Value="Red"/&gt; &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;DataGrid Style="{StaticResource MyDataGridStyle}"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Binding="{Binding Text}"/&gt; &lt;DataGridTextColumn Binding="{Binding Tag}"/&gt; &lt;/DataGrid.Columns&gt; &lt;DataGrid.Items&gt; &lt;TextBlock Text="Item1" Tag="aa"/&gt; &lt;TextBlock Text="Item2" Tag="bb"/&gt; &lt;TextBlock Text="Item3" Tag="cc"/&gt; &lt;TextBlock Text="Item4" Tag="dd"/&gt; &lt;/DataGrid.Items&gt; &lt;/DataGrid&gt; &lt;/Window&gt; </code></pre> <p>the results are </p> <p><img src="https://i.stack.imgur.com/4407Y.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload