I am trying to have the SizeToContent="WidthAndHeight" and WindowState = "Maximized" at the same time. I tried to change the state of my window during loading, as well as in the Constructor of the MainWindow, but no luck.
<Window x:Name="MainWindowMy" x:Class="ManyTabControls.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Pressure Vessel Design" WindowState="Maximized" SizeToContent="WidthAndHeight" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" Loaded="MainWindowMy_Loaded" >
<Window.Resources>
I have got a TabControl with a lot of tabs, in the design viewer, tabs are flowing down into different rows. And when I change the width of the TabControl so that the tabs be in the same line, then they go outside the boundary of the MainWindow. And if I set the width of the Mainwindow, then the MainWindow would have a constant width. That means if the size of monitor gets smaller, then part of the MainWindow that is bigger than the screen will not be displayed. I hope I made myself clear.
Maximised
andSizeToContent
to work together? They are contradictory. What do you expect to happen? – dkozlMaximised
means that the window regardless of its contents must fill entire screen space,SizeToContent
means that regardless of its size it must shrink or increase its size to fit the contents. They are completely incompatible, because they act differently under the same circumstances, but due to the order of layout calculationsSizeToContent
has greater priority (or some sort of). And how should they work both at the same time? For example, your have 1 control 100x100 pixels and your screen is 1000*500, how should the layout look like? – Eugene Podskal