Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>first of all, I'd advise you to update to .net 4.0 to be able to use the WPF dataGrid without resorting to installing the WPFToolkit.</p> <p>now as for your issue, you have to set a style to your datagrid, and inside the style, template or resource put this kind of code:</p> <pre><code> &lt;Style TargetType="{x:Type Button}" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}"&gt; &lt;EventSetter Event="PreviewMouseDown" Handler="SelectAllButtonPreviewMouseDownHandler" /&gt; &lt;EventSetter Event="PreviewMouseUp" Handler="SelectAllButtonPreviewMouseUpHandler" /&gt; &lt;Setter Property="ToolTip" Value="{Binding SelectAllButtonToolTip, RelativeSource={RelativeSource AncestorType=DataGrid}}" /&gt; &lt;Setter Property="Content" Value="{Binding SelectAllButtonContent, RelativeSource={RelativeSource AncestorType=DataGrid}}" /&gt; &lt;Setter Property="Focusable" Value="False" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Grid Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"&gt; &lt;Polygon Name="Arrow" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,3,3" Points="0,9 9,9 9,0" Fill="Black" Opacity="0.15" Visibility="Collapsed"/&gt; &lt;ContentPresenter Name="ContentSite" /&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="Content" Value="{x:Null}"&gt; &lt;Setter TargetName="ContentSite" Property="Visibility" Value="Collapsed"/&gt; &lt;Setter TargetName="Arrow" Property="Visibility" Value="Visible"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter TargetName="Arrow" Property="Opacity" Value="0.75"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>(this is a sample from some code of mine, that I put in MyDataGrid.Resources, MyDataGrid being a class derivated from DataGrid)</p> <p>edit: the important part is of course the <code>x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}"</code> in the button's style declarator.</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