I have a view in XAML where I have a listbox, and a selection in that listbox populates an area to the side with properties from the selected instance of the ChildViewModel. I have a few buttons in the ChildView that are connected to commands in the ChildViewModel. Before I make a selection from the parent listbox, these buttons do nothing as expected. How could I keep these buttons hidden until a selection selection in the parent listbox is made, thus creating an instance of the ChildViewModel.
I know how I could accomplish this if these buttons were part of the parent view by binding the visibility of these buttons to {Binding SelectedItem, ElementName=listBoxName}. However, I am having a hard time accomplishing this within the ChildView because I do not have access to (and do not want to be dependent on) the element from the parent view. Please help me accomplish this, preferably purely within the XAML code.
You should be able to just check if the datacontext of the childview is null (i.e. no ChildViewModel set). If it is null hide the buttons.
Set the ancestor to whatever container is holding your child view