I have a window with a TabControl that has three TabItems. This TabControl is the main control in the window, and I want to size the window based on this TabControl.
If I set SizeToContent="WidthAndHeight" on the window, the window changes size when I select a tab which has content that takes more area. I want the window to start at a fixed size based on the TabItem that will take the largest amount of space. This is not the starting tab.
A TabItem's ActualWidth is the width of the button. The content of an inactive TabItem (a grid) has an ActualWidth of 0 and a Width of NaN because it is not being displayed.
How can I set the window to a fixed size based on the content of the largest TabItem, which is not selected? This would preferably happen at Window_Loaded or Window_ContentRendered.