Hello Team,
I am using XAMDatagrid in WPF. I have used "GroupByPresenter" style to group the records with Checkbox in group row. I am selecting child group records on clicking of checkbox in Header row.
Now I have two issues.
1) I have two level grouping - so want check checkbox of second level group when first level(Main Parent) level group checkbox is checked.
2) When user clicks anywhere in area of group row selection of child rows is removed.
I have attached video to give u better understanding of my problem.
It would be great help if u can provide me a solution.
Thanks & Regards,
Vikram U
I have attache my code in zip file.
Basically second issue is that,
Suppose I have Hierarchy like below
Parent1 - Group Row
SubParent1 - Group Row
Child1.1 - Normal Data row
Child1.2 - Normal Data row
Parent2 - Group Row
SubParent2 - Group Row
Child2.1 - Normal Data row
Child2.2 - Normal Data row
Now If I click On Parent1 checkbox it selects all the child rows under that parent means Child1.1 and Child1.2
Now If I click anywhere in group area or somewhere else in XAm grid it removes the selected rows (Child1.1, Child 1.2)
I haven't tried your code will do and let u know the result.
Thanks,
Vikram
Hello Vikram,
I have created a sample project based on the relevant styles and code-behind that you have provided. The reason that you are seeing the deselection behavior that you are is due to a mix between the inability to select records from different layouts, and the fact that the GroupByRecords can be selected by clicking on them. There are a couple of points in the code that you have provided that could have this effect.
First, in the MouseLeftButtonDown event handler for your MySTACK StackPanel, you are not marking this event as handled, and so it will bubble up to the GroupByRecordPresenter and fire its record selection code. So, if you click on the GroupByRecordPresenter, it will expand, try to select the child records that belong to it, and then the event will bubble out and select the GroupByRecord, which will deselect your child records. I would recommend setting the e.Handled property on this event to "True" to prevent this, where e is the event arguments.
The order of selection in the SetSelectionChild method is doing something very similar to the above, where the selection order seems to be happening along the lines of DataRecords => GroupByRecord => DataRecords. If you only have a single GroupByRecord in the child grouping band, this is fine, but with multiple, it will only work for the last set of DataRecords due to the layout selection issue mentioned above. If would recommend making a check in your SetSelectionChild method to prevent the selection from happening if your "rec" variable is a GroupByRecord.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer