Hi,
My situation is that for displaying fields in XamDataGrid, I have AutoGenerateFields="True" and then I collapse the fields in FieldLayoutInitialized event which I don't need. And then also in FieldLayoutInitialized event I have also set CellVisibilityWhenGrouped = Visibility.Collapsed with one of the field (lets call this field A ). I am also displaying another field (lets call this field B in the same column as field A but in 2nd row having field A in first row.)
Now what I want to do is since field A's CellVisibilityWhenGrouped = Visibility.Collapsed, its collapsed when grouped but field B in same column still remains visible. How can I make field B collapsed as well when field A is collapsed when its grouped.
I tried binding field B's Visibility with field A's Visibility but it didn't work.
Binding bin = new Binding(); bin.Source = layout.Fields["A"]; bin.Path = new PropertyPath("Visibility"); BindingOperations.SetBinding(layout.Fields["B"], Field.VisibilityProperty, bin);
Your help will be much appreciated.
Thanks,
Imad.
I tried this. It works but it doesn't seem the prettiest way to handle this. As it would execute each time when any column is grouped.
Hello,
Thank you for your post. I have been looking into it and since the Visibility Property doesn’t change, if the Field is hidden only, when grouped, and the VisibilityResolved Property, which changes, is read only, I suggest you add the following code in your XamDataGrid’s Grouped event:
e.FieldLayout.Fields["B"].Visibility = e.FieldLayout.Fields["A"].VisibilityResolved;
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Anyone ?