Hi,
I've a column in my XamGrid having checkbox to select/unselect a record.
I also have a "SelectAll" checkbox in the header of the xamgrid (created using HeaderTemplate of my TemplateColumn).
Now, when I "group" my rows on a column, I see the header gets repeated for each group (so as the "SelectAll" checkbox).
My requirements are:
1. Should be able to know what group it is when the "selectAll" checkbox (of certain group header) is clicked. I am handling Click event of the "selectAll" checkbox, and all different group header checkbox click land into same handler in the code behind.
2. Should be able to "Hide" the "SelectAll" checkbox in the header for certain group! on certain condition. Say, a group is having only one row, then I may not want to show the "selectAll" checkbox for this group.
I even tried using the Loaded event for "SelectAll" checkbox, so to build a collection of such loaded checkboxes and handle them via code.
But, this fails when the checkboxes keep "Loading" when I switch the tabs in my application.
Thanks and Regards.
Hello Vijay,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into it and I created a sample project for you with the functionality you want. Basically I bound the CheckBox’ Visibility Property to the Rows’ Count and used Converter to make it visible or not.
Feel free to write me if you have further questions.
I guess, I was a little too quick to post the question.
I found this solution for the 1st part of my post.
http://ko.infragistics.com/community/forums/t/60063.aspx
XAML:
<ig:CheckBoxColumn Key="Bool"> <ig:CheckBoxColumn.HeaderTemplate> <DataTemplate> <CheckBox Click="CheckBox_Click" /> </DataTemplate> </ig:CheckBoxColumn.HeaderTemplate> </ig:CheckBoxColumn>CODE:
private void CheckBox_Click(object sender, RoutedEventArgs e) { CheckBox cb = (CheckBox)sender; HeaderCellControl cell = (HeaderCellControl)cb.Parent; foreach (RowBase row in cell.Cell.Row.Manager.Rows) { if (row.RowType == RowType.DataRow) { ((MyDataObject)row.Data).Bool = (bool)cb.IsChecked; } } }
However, (nothing to do with above solution), many a times, the group header checkboxes for different groups behaves incorrectly. Like clicking on one group header checkbox, select/unselect other group header checkbox as well.
I still need solution for 2nd point, i.e., need to find a way to "hide/remove" certain group header checkbox from the header.