Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We do something similar in our app.</p> <p>What i have done is derived my own column type (DataGridSearchableBooleanColumn), then i replace the DataGridColumnHeader template, i put two content presenters in there. the first i bind to the content (the same as the default template) the second i bind to the column. I use a data template for the column (i have a few of them for different search types (text, combo, boolean). then i add the extra properties to the column so i can bind to them. See if this code makes sense.</p> <pre><code> &lt;!--Style for the datagrid column headers, contains a text box for searching--&gt; &lt;Style x:Key="columnHeaderStyle" TargetType="dg:DataGridColumnHeader"&gt; &lt;Setter Property="Foreground" Value="#FF000000" /&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Left" /&gt; &lt;Setter Property="VerticalContentAlignment" Value="Center" /&gt; &lt;Setter Property="IsTabStop" Value="False" /&gt; &lt;Setter Property="Padding" Value="1,2,1,2" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="dg:DataGridColumnHeader"&gt; &lt;Grid x:Name="Root"&gt; &lt;dg:DataGridHeaderBorder Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" IsClickable="{TemplateBinding CanUserSort}" IsHovered="{TemplateBinding IsMouseOver}" IsPressed="{TemplateBinding IsPressed}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}" SortDirection="{TemplateBinding SortDirection}"&gt; &lt;Grid HorizontalAlignment="Stretch" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"&gt; &lt;Grid.Resources&gt; &lt;DataTemplate DataType="{x:Type local:DataGridSearchableBooleanColumn}"&gt; &lt;CheckBox Margin="0,5,0,0" IsThreeState="True" IsChecked="{Binding Path=IsChecked}" /&gt; &lt;/DataTemplate&gt; &lt;/Grid.Resources&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="19" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, Path=Content}" /&gt; &lt;Path x:Name="SortIcon" Fill="#FF444444" Stretch="Uniform" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Grid.Column="1" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z "&gt; &lt;Path.RenderTransform&gt; &lt;ScaleTransform ScaleX=".9" ScaleY=".9" /&gt; &lt;/Path.RenderTransform&gt; &lt;/Path&gt; &lt;ContentPresenter x:Name="columnHeaderContentPresenter" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Column}" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,0,0,0" /&gt; &lt;/Grid&gt; &lt;/dg:DataGridHeaderBorder&gt; &lt;Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left"&gt; &lt;Thumb.Style&gt; &lt;Style TargetType="{x:Type Thumb}"&gt; &lt;Setter Property="Width" Value="8" /&gt; &lt;Setter Property="Background" Value="Transparent" /&gt; &lt;Setter Property="Cursor" Value="SizeWE" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt; &lt;Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Thumb.Style&gt; &lt;/Thumb&gt; &lt;Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right"&gt; &lt;Thumb.Style&gt; &lt;Style TargetType="{x:Type Thumb}"&gt; &lt;Setter Property="Width" Value="8" /&gt; &lt;Setter Property="Background" Value="Transparent" /&gt; &lt;Setter Property="Cursor" Value="SizeWE" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt; &lt;Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Thumb.Style&gt; &lt;/Thumb&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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