While creating a simple custom expander, I encountered the problem where items inside IT wouldn't bind. I found the fix on this link:
http://codeoverload.wordpress.com/2012/03/04/wpf-expander-headertemplates-dont-forget-the-binding/
Which happens to treat that exact same issue, however what I understand from it is "found this by luck, not really sure why it worked ;D"
My question being now: why does adding Header={Binding} fixes the issue. Indeed from the fact binding wouldn't work, it seems it's due to the DataContext, but I don't see how this should fix it.
Thanks for explaining; hopefully this isn't a duplicate >.<
From the docs
That object being a binding against the DataContext, or plain text, or whatever.
I'd bet the implementation looks to see if the value is text, and if so, throws it into the default header template which could be something as simple as
If you declare a template for the header, the
DataContext
will be whatever you assign to the Header property. TheDataContext
of the Expander doesn't flow automatically to the header template, apparently.