将SelectAll CheckBox添加到wpf datagrid列?

时间:2016-03-23 21:26:11

标签: wpf xaml checkbox wpfdatagrid selectall

如果你可以帮助我,我想在我的wpf数据网格的第一列添加一个selectall复选框,我该怎么办?感谢。

                       <DataGrid.Columns>
                            <DataGridCheckBoxColumn ElementStyle="{DynamicResource MetroDataGridCheckBox}"
                                    EditingElementStyle="{DynamicResource MetroDataGridCheckBox}"
                                    Header="Select"
                                    Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=IsSelected, Mode=OneWay}"                                                        
                                    />                               

                            <DataGridTextColumn Header="Matricule" Width="100"  Binding="{Binding Matricule}"/>
                            <DataGridTextColumn Header="Nom" Width="80" Binding="{Binding Nom}"/>
                            <DataGridTextColumn Header="Prenom" Width="80" Binding="{Binding Prenom}"/>
                            <DataGridTextColumn Header="Date Recrutement" Width="120" Binding="{Binding Date}"/>
                            <DataGridTextColumn Header="Telephone" Width="100" Binding="{Binding Telephone}"/>
                            <DataGridTextColumn Header="E-mail" Width="120" Binding="{Binding Email}"/>
                            <DataGridTextColumn Header="Compte" Width="80" Binding="{Binding CompteFonct}"/>
                            <DataGridTextColumn Header="Banque\CCP" Width="80" Binding="{Binding CodeBanque}"/>                                

                        </DataGrid.Columns>
                    </DataGrid>

1 个答案:

答案 0 :(得分:0)

请在网格内使用ComboBox模板。请查看以下链接以供参考。

methods http://www.codeproject.com/Articles/563862/Multi-Select-ComboBox-in-WPF