I have userControl with a GridView of GridViews (A GridView who’s data context is another GridView) so when i set the itemssource to a collection of collection i can see a hierarchical view.
eg:
Parent Collection is
List<ClassRoom>and the parent Collection has aPropertyList<Student>
The above Classes are defined and i can’t modify the class(as we consider it is in Model Layer) for the use of my UserControl.
Because i am developing a UserControl i have defined a Property called bool ShowChildItems.
if ShowChildItems is set to false i want the childGridView to be Collapsed.
How can i bind the property of the user control to childGridView.Visisbility.
(ShowChildItems property value may change at runtime,depending on the instance of the UserControl)
To have a
ShowChildItemsproperty in yourUserControlto manage theVisibilityof your childGridViewyou first need to make it aDependencyProperty:Inside the
UserControlyou will bind theGridViewVisibilityto this property by using theElementNamesyntax – this way it doesn’t matter what theGridViewDataContextis bound to:For this to work you need to set the name to
UserControl‘s root node (I’ve omitted the rest of the attributes):I’ve also used a converter to bind a
boolproperty toVisibility:This is its code:
I hope this is what you were asking for. I’m not quite sure based on your question.