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 Josh,
I have implemented the application in somewhat different manner using your code.
I am attaching the sample code which I have implemented. Can you please go through it and let me know what is the problem?
When you will run it, the header checkbox state is not maintained when u switch between the tabs.
Thanks and Regards,
Sejal
Hi Sejal,
I just downloaded the sample app on my blog post that shows how to put checkboxes in the record selectors. I put the sample's XamDataGrid into a TabItem, which is in a TabControl. I added another TabItem to the TabControl that had no content. When I run the app, I check a checkbox, select the other TabItem, and then select the TabItem with the XamDataGrid. After doing that, the checkboxes maintained their check state. So, I can't reproduce the problem you've listed. Does following those steps not work properly for you?
Thanks,
Josh
Hi Josh Smith,
I tried the code you provided for adding checkbox in the XamDataGrid using LabelPresenterStyle. Its working perfectly as expected behaviour.
But when I put the xamdatagrid in tab as tabitem and when i switch between the tabs, the checkbox state in the LabelPresenter is not maintained.It gets unchecked everytime on GUI when I switch between tabs.
Please let me know if any solution to this.
I just blogged a solution that shows how to put CheckBoxes in the record selectors and header area, and give them built-in smarts to check/uncheck properly. If you are interested, here's the link:
http://blogs.infragistics.com/blogs/joshs/archive/2008/09/04/adding-checkboxes-to-the-record-selectors-in-xamdatagrid.aspx
Hy Althea.
In my grid I have a list of countries and I set the DataSource of the grid to this Collention of country objects. My Country object has a property called Selected and this property it's bounded to the RecordSelector as you can se in this example.
To get all the selected countries from the grid I check the value of this propetry.
I think there is a property for a Record object from the grid called IsSelected to see if this Record is selected or not. Try to bind this property to the checkbox of the RecordSelector. Maybe this will help:
<CheckBox DataContext="{Binding ElementName=listNote, Path=ActiveRecord}" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
{
}