WPF Expander and Window resizing after collapse? WPF Expander and Window resizing after collapse? wpf wpf

WPF Expander and Window resizing after collapse?


The SizeToContent property seems to lose its value as soon as you resize the Window manually, to fix this just subscribe to the OnSizeChanged event of your Window, and reset the SizeToContent property:

XAML:

<Window SizeToContent="WidthAndHeight" SizeChanged="MainWindow_OnSizeChanged">

Code-Behind:

private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e){    SizeToContent = SizeToContent.WidthAndHeight;}