Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a ControlTemplate for a DataGridRow in WPF
    text
    copied!<p>What I am trying to accomplish is customize the <code>DataGrid</code> control so that each row has rounded corners, no gridlines (just the design I'm working with).</p> <p>What I have been trying to do is create a <code>ControlTemplate</code> that modifies the <code>DataGridRow</code> controls so that they have the expected appearance. So far, this is what I am working with:</p> <pre><code> &lt;DataGrid Grid.Row="0" Grid.Column="0" Margin="5,5,5,5" AutoGenerateColumns="False" ItemsSource="{Binding Path=MyData}"&gt; &lt;DataGrid.Resources&gt; &lt;Style x:Key="rowStyle" TargetType="{x:Type DataGridRow}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type DataGridRow}"&gt; &lt;Border CornerRadius="8,8,8,8" BorderBrush="Red" BorderThickness="2"&gt; &lt;ContentPresenter /&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/DataGrid.Resources&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="Foo" /&gt; &lt;DataGridTextColumn Header="Baz" /&gt; &lt;DataGridTextColumn Header="Bar" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>This version would obviously be rudimentary (simply a border around the stock template), but I cannot see any difference when I run the application.</p> <p>The question, then, is how do I customize the control template for a DataGridRow? Or, if this is unworkable, is there a better way to go about accomplishing my aims:?</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