This project has moved. For the latest updates, please go here.

Autogenerated colums with DataGridFilterColumn.Template

Aug 27, 2014 at 4:50 AM
How can I use the AutoGenerated columns but specify a template to be used on all of the generated columns. For example, how can I apply a FilterWithPopupControl on all of my AutoGenerated columns.

This is different from what is shown in the docs as I don't want to specify just the filter.. but also the template?

Is this possible?
Coordinator
Aug 30, 2014 at 1:56 PM
It's like in the "Extended 1" sample:
You can override anything in "generic.xaml" that has a public resource key defined in the DataGridFilter class.
These are the default control templates, just add yours with the same keys anywhere in the resources of your application.
  <!-- Default template for a filter on a colum represened by a DataGridTextColumn. -->
  <ControlTemplate x:Key="{x:Static src:DataGridFilter.TextColumnFilterTemplateKey}">
    <Grid>
      <Control Style="{DynamicResource {x:Static src:DataGridFilter.IconStyleKey}}"/>
      <TextBox Style="{DynamicResource {x:Static src:DataGridFilter.ColumnHeaderSearchTextBoxStyleKey}}"
          Text="{Binding Path=Filter, UpdateSourceTrigger=PropertyChanged}"/>
    </Grid>
  </ControlTemplate>

  <!-- Default template for a filter on a colum represened by a DataGridCheckBoxColumn. -->
  <ControlTemplate x:Key="{x:Static src:DataGridFilter.CheckBoxColumnFilterTemplateKey}">
    <Grid>
      <Control Style="{DynamicResource {x:Static src:DataGridFilter.IconStyleKey}}"/>
      <CheckBox Style="{DynamicResource {x:Static src:DataGridFilter.ColumnHeaderSearchCheckBoxStyleKey}}"
         IsChecked="{Binding Path=Filter, UpdateSourceTrigger=PropertyChanged}"/>
    </Grid>
  </ControlTemplate>
Sep 3, 2014 at 4:54 AM
Thanks for the reply.

So I'm not sure how to proceed properly when I have my PopupFilterControl as a UserControl. How do I set the ControlTemplate to be my UserControl?
Sep 6, 2014 at 5:16 PM
..any idea here? I'm not that familiar with how to set the Control Template to be my UserControl?
Coordinator
Sep 13, 2014 at 10:31 AM
<ControlTemplate x:Key="{x:Static src:DataGridFilter.TextColumnFilterTemplateKey}">
  <local:MyUserControl/>
</ControlTemplate>