Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Ancestor binding not working for expander!

$
0
0

Hi everyone,

I have a project in which I have a user control with ItemsControl, whose ItemSource I bind to a collection of views.

Each view contains an Expander and all contents are within that.

This works fine and I can see all the views getting loaded.


So it looks something like this:

Now, there is an Expand/Collapse all  toggle button on top, in the parent view control.

I want to expand all the views when I click on that button.

So for each expander I added:

IsExpanded="{Binding XPath=ExpanderProperty.IsChecked, RelativeSource={RelativeSource AncestorType={x:Type ParentControl}}, UpdateSourceTrigger=PropertyChanged}"

where ExpanderProperty is a property defined in the parent view control which returns the Button:

public Button ExpanderProperty 

{

get  { return ToggleButtonExpandAll; }  

}

This doesn't work. I checked using WPFInspector for any binding errors etc, but no, its all clean.

One more interesting fact it, this works when WPFInspector is running and the expander is in focus (selected)

What am I doing wrong?

Thank you.


Please Mark as Answered If this answers your question OrUnMark as Answered if it did not.
Happy to Help :)
My Site


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>