A while ago I posted a blog entry called Stretching Content in an Expander Header which discussed a way to make the content of an Expander’s header occupy all available space in the header area. The solution I proposed back then required the use of some code to do the trick. Today a fellow by the name of Patrick Jones posted a comment which shows a clean solution. His solution still requires the use of code.
After reading over his sample I realized that it is possible (and easy) to implement the functionality without writing any code at all. The original post has been updated to show the XAML-only solution, which I like the best out of all three options (if you do not care that the header element will be clipped on the righthand side). Here’s the relevant XAML snippet:
Text=”I am header text…”
I am some content…
NOTE: Be sure to read the original post to learn about the limitations of this XAML-only approach, and when it is necessary to use the original technique.