Hy.
I have a question about the RecordSelector's header for the XamDataGrid.
I have a XamDataGrid for which I have changed the template for the RecordSelector to contain a checkbox for selecting the records. This checkbox it's bounded to a property of the objects displayed inside the grid. Everything work's fine. But I would like to change the header of the RecordSelector to contain also a checkbox, with the select all functionality. I have no idea how to reference the header of the RecordSelector. Is there a way to do this?
<Style x:Key="CheckBoxSelector" TargetType="{x:Type dataPresenter:RecordSelector}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type dataPresenter:RecordSelector}">
<CheckBox IsChecked="{Binding Path=DataItem.Selected, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Thanks very much
Nico
Hi. I have re-used this implementation, checkboxes are ok, as well as the header but I'm stuck now how to get the checked/selected data rows in the xamdatagrid. How to achieve this? Your reply is greatly appreciated! Your support is my pleasure. Thank you very much in advance.
Regards,
Althea
The best way to understand the structure of any WPF control's element tree is to use the free Mole and Snoop tools. I use those tools all the time when trying to do customizations of a control.
Hy Josh.
So this it's how it's called......HeaderPrefixArea......This was my problem because I didn't know how the header of the RecordSelector was called and I didn't know for what property of the grid to set the template.....
Thanks so very much. Now it's perfect......Thanks again.
Hi Nico,
It turns out that there's an easier, and cleaner, way to do this. Add this Style to the XamDataGrid's Resources collection, and you're good to go:
<Style TargetType="{x:Type igDP:HeaderPrefixArea}"> <Setter Property="Visibility" Value="Visible" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:HeaderPrefixArea}"> <CheckBox Click="OnHeaderCheckBoxClick" VerticalAlignment="Center" HorizontalAlignment="Center" /> </ControlTemplate> </Setter.Value> </Setter></Style>
Josh