This project has moved and is read-only. For the latest updates, please go here.

DataGrid - Add little button for filtrer in column Header

Nov 25, 2013 at 3:56 PM
Hello,

I work with the lasted version of DataGrid.

I would like add a function filter and I want add a control in my column header.

I want to keep the header default style and simply add a small button to right.

I writted this code
<Style TargetType="{x:Type xcdg:ColumnManagerCell}">
                                                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                                    <Setter Property="HorizontalAlignment" Value="Center"/>                                                    
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type xcdg:ColumnManagerCell}">
                                                                <Grid>
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="*"></ColumnDefinition>
                                                                        <ColumnDefinition Width="Auto"></ColumnDefinition>                                                                        
                                                                    </Grid.ColumnDefinitions>
                                                                    <ContentPresenter Grid.Column="0"
                                                                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                                      ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                                                      Style="{TemplateBinding Style}">                                                                       
                                                                    </ContentPresenter>
                                                                    <Button Grid.Column="1" Background="Transparent" ToolTip="Filtrer...">
                                                                        <StackPanel>
                                                                            <Image Source="Resources\Ajouter.png" Width="16" Height="16"></Image>
                                                                        </StackPanel>
                                                                    </Button>
                                                                    <Button Grid.Column="1" Content="..."></Button>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
Thank you for your help.