wpf stackpanel fill parent. How to: Horizontally or Vertically Align Content in a StackPanel . wpf stackpanel fill parent

 


 How to: Horizontally or Vertically Align Content in a StackPanel 
wpf stackpanel fill parent  But it's just a hack, not a real solution

It is the StackPanel's "fault". This problem occurs because WPF's default template for TreeViewItem is set up as a 3-column by 2-row Grid. Because there's nothing to constrain the width of the TextBlock, it doesn't wrap. 2 Answers. ZIndex to place the "Overlay" on top of everything else. 61 C# MIT License Created about 9 years ago. WPF layout issue with nested. Panels Overview. They normally leave a blank space. The example manipulates the property value by using two Button elements; each element represents one of the Boolean property values. The code listed in Listing 8 places four Button elements on a StackPanel and sets the HorizontalAlignment property to Left, Center, Right and Stretch. WPF TextBox won't fill in StackPanel. In the right column there might be three items or there might be 10. How do I set the parent background color only for child control without showing any background color in the parent? I have added a sample code and screen here. StackPanel. However, WPF supports this feature in a different manner using an asterisk (*) suffix with a double number. ItemsSource = new List<Item> {. How to make StackPanel to fill his container with and height in WPF. Bind the Height of the StackPanel or Grid to the ActualHeight of the parent. Finding the size of the parent is needed to size the intermediate panel otherwise it would be flat and its content hidden - an absolute value would work as well. Add this to the parent Grid and set it to true. If it's something like Stackpanel you can check the Children-Property. Here's an alternative solution I've used in the past that separates out the "Overlay" from the rest of the content. StackPanel. Expand stackpanel and child controls to fill screen width on various devices. You think about exactly what you want to do and use a grid rather than a stackpanel. A StackPanel, by default (If orientation is Vertical) gives each child item maximum width available but only the required height! If your required height is more than what is available (Like in you example), it will be clipped! Their is a few workarounds for this problem: 1) Fixed width (This sucks!)Or if it is possible to have another conntainer which could be parent of stackpanel and also supports IsEnabled property. There are 2 possible events: SizeChanged and LayoutUpdated. The child controls have to return how big they want to be (positive infinity is not a valid return from the MeasureOverride in either axis) so they return the smallest. StackPanel. StackPanel element, and also how to adjust the xref:System. Open side panel. DockPanel. For. The left side of the window will show the content of the uploaded files in my app and the right side should have a list of all the uploaded files in a ScrollViewer for the. StackPanel has a specific purpose among other layout containers. The HorizontalAlignment="Stretch" did not work. WPF - Resizing Children to Fill a Parent. What you want to do is replace the Canvas element with a plain Grid element (you don't need to define rows or columns. autogrid c-sharp dotnet +7 more tags. Example. Can a Border fill the space of a Stackpanel without setting the width explicity? 5. I have a custom control that passes a TextBox to ContentPresenter through Content in the middle, but I can't bind the text of the TextBox outside,The code is as. In the meantime, the only thing I can suggest is binding Bounds. I notice from your code block that your StackPanel is already docked inside a dockpanel, so I've included the. TemplatedParent is a property, which enables you to create a Control template with few unknown values. StackPanels do not allow for this kind of layout, they just stack things, giving their children the amount of space they request (and not more). Represents a spinner control that includes two Buttons. Also, I've always wanted a simple container which would apply a margin but only between child elements. By defining <RowDefinition/> elements, you can give your child elements special heights like Auto (take as much space as you need) and * (take the remaining space). The logical parent of the element is therefore ContentControl. 4 Answers. 8?: Yes; Problem description: If you create a StackPanel, with horizontal orientation, and put a textbox within it (with the default auto width) the textbox doesn't fill the Stackpanel, it defaults to a width of 6. To get past this point and extend into the logical tree where the template is actually applied, use TemplatedParent. Children. Row="1" HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled". oh and in particular, star-sizing can only be done on either the ColumnDefinition. A third Border. So the simple solution is: remove the StackPanel. <ItemsControl> <!-- target the wrapper parent of the child with a style --> <ItemsControl. But you can bind its MinWidth and MinHeight properties to its container's width/height. But I see now way to do it other than setting an explicit width on the Border . StackPanel, UniformGrid, WrapPanel, DockPanel and Grid. Anyway, if what you're trying to do is make the group headers "full width", you will have to override the GroupStyle's ItemContainerStyle, and set the Header ContentControl's. Learn how to create a StackPanel, which allows you to stack elements in a specified direction, via the included example in XAML. You can resize the Window and you will see the ScrollViewer appears and disappears when the Windows is smaller and larger. It is one of the popular panels because of its simplicity. Or you can rotate the StackPanel 180 degrees to get the buttons to stack from the bottom to the top and then rotating the buttons another 180 degrees to get them right-side-up again: <StackPanel> <!-- rotate all buttons inside this panel --> <StackPanel. You have to set ScrollViewer. csWPF supports a rich set of control containers derived from the base Panel class. Windows. I know that StackPanel does not resize content but then again I need. It is very simple, it has one Border, on label and one button. Observe that in this case the StackPanel will determine how much horizontal space is available and allocated it to the child controls. In the following XAML the button will stretch to fit the width of the window, including as you resize the window. Apply the same logic for rows which have to be declared inside the Grid's RowDefinitions property. Column="0" Text=" {Binding Name}" />. <ItemsControl. Parent elements call this method from their ArrangeCore(Rect) implementation (or a WPF framework-level equivalent) to form a recursive layout update. Markup; namespace WpfTestBench. bind to the ActualWidth and ActualHeight properties: <Binding RelativeSource=" {RelativeSource. By definition, a stackpanel has infinite length. To get around this you can use a DockPanel. Second, setting Width and Height within the UserControl will set its size to that fixed size, so it will not. Figure 2. Load 7 more related. and: <DockPanel LastChildFill="False"></DockPanel>. In Babylon GUI, the width/height are relative to the parent container. Both the StackPanel and the ComboBox are set to stretch, but they. What I want is to set the height of the vertical stacks to the actualheight of the outer horizontal stack. Here is the dynamic approach: <RowDefinition x:Name="NavigatorRow" Height="1*"/> <RowDefinition x:Name="TaskPanelRow" Height="80"/>. Stretch is the default for both alignment properties. I have a MainWindow and inside this MainWindow I have a UserControl loaded. The child elements that have no specified Width stretch to fill the parent window; however, the child elements that have a specified Width, are centered within. Firstly your layout is kind of a mess. Data. 1 Answer Sorted by: 24 You can make the Content of every ListBoxItem stretch by setting HorizontalContentAlignment in the ItemContainerStyle <ListBox. Also, I've always wanted a simple container which would apply a margin but only between child. Connect and share knowledge within a single location that is structured and easy to search. The following XAML shows how to create a. In my WPF application, I have added ItemControl and I set the background color in it. StackPanel. Apr 6, 2015 at 19:06. . 13. )Example. StackPanel is typically used to arrange a small subsection of the UI on a page. The fix that worked for me was to disable the horizontal scrollbar, which, apparently, also tells the container of all those items to remain only as wide as the list box. In the meantime I'll try to work out how this works in WPF. It is automatically stretching horizontally when I resize the window, but the vertical height of the Canvas will not fill up the rest of the containing objet. (Inherited from Panel). – Shimmy Weitzhandler. In the XAML above , I want to dock the ListView on the StackPanel. 0. <ContentControl Content=" {Binding Path=ChildView}" Margin="10" />. These include Canvas, DockPanel, StackPanel, WrapPanel, and Grid. The . Stretch (Default) Child elements are stretched to fill the parent element's allocated layout space. Dec 27, 2009 at 23:54. _ window width_ _. In your case, you want it to display the Name property of the Mode class, so you can use the following XAML code to set the ItemTemplate: <ListBox SelectionMode="Single" MaxHeight="30" ItemsSource=" {Binding}" DataContext. Wiki Security 2 Insights New issue Auto Width of TextBox doesn't fill Horizontal StackPanel correctly #6759 Closed JamesC01 opened this issue on Jul 6, 2022 · 2. When you have a TextBlock that has a lot of text, it is impossible to wrap that text without setting an explicit width. So try something like this:Place all your scrollable elements here --> </Grid> <!--. Here is the XAML. Column="0" Text=" {Binding Name}" /> <TextBox Grid. Windows. The upper left and upper right corners of the blue border and the lower left and lower right corners of the red border are sticking out of the curved edges of the first. Create a new Visual and use it to set the Visual property of the VisualBrush. Add (realImage); The StackPanel does not enlarge to 50px though; it's stuck to 10px, cutting. a Parent property). The WrapPanel class in WPF represents a WrapPanel. Sorted by: 88. The most typical scenario for using the Parent property is to obtain a reference and then get various FrameworkElement property values from the parent. Columns work the same way. Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Talent Build your employer brand ; Advertising Reach developers & technologists worldwide; About the companyStackpanel places controls based on PositiveInfinity, which means the size that it can take in positive direction. I have the following code, I think the List should fill out the entire space occupied by the stack panel, I tried using Grid but it didn't work. I want to arrange 2 Grids (or StackPanels) incl. Since your StackPanel has an Horizontal orientation, the TextBlocks with just keep stacking, well, horizontally. StackPanels have infinite client size, so nothing inside a StackPanel will wrap or trim without explicit dimensions being set (instead, the StackPanel just grows to fit the contents). it's to "Stack" items vertically/horizontally and works based on it's children's desired height than what's available. (readonly)ExtentHeight - Gets a value that contains the vertical size of the extent. I want to bind the Height of the ListBox to the Height of the StackPanel so the ListBox stretches itself Vertically so the green area is not visible anymore. StackPanelSample. Columns and rows that are defined within a Grid can take advantage of Star sizing to distribute remaining space proportionally. I would like that on form display content is resized proportionally to the screen size. If your path has its spacing laid out that you want the center of the circle to be in the center of the display area, your path has to have coordinates that are relative to its container. The scroll viewer is also set to 100%, which is 100% of the stack panel, and so in the end its height = height. 3. The following code snippet creates a. It's because you're using Horizontal orientation on the StackPanel. The labels and custom radio buttons behave as I expect, but the textboxes will not stretch horizontally to fill the viewbox (sorry can't post image because of rep). That means that the StackPanel is giving full width to each child control, and then laying them out horizontally - even if that means exceeding its bounded/visible width. Height property. If you want automatic resizing, just replace the StackPanel s with `Grid. So, is there a way I can get the behavior I want with the out-of-the box panels?Any Panel such as a StackPanel uses a measure-arrange cycle to decide on a layout for its child elements: The key feature of a StackPanel is that it has infinite space -- infinite horizontal space if its orientation is Horizontal, and infinite vertical space if Vertical. WPF StackPanel content vertical alignment. the StackPanel stays on its position (Stay on top, don't go under) while the window is minimized. How to make StackPanel to fill his container with and height in WPF. I need to be able to fill a stackpanel with buttons but the buttons must appear at the bottom of the stackpanel first and populate upwards. I'm attempting to stretch the height of a ListBox 100% of the height of the parent grid (i. I had my Grid inside a StackPanel and the StackPanel was forcing the Grid to be as small as possible, thus the TextBox wouldn’t expand either. it works perfectly fine over here: I copy-and-paste the above code in a XAML window -> the red. For instance, if a list has a 50% (0. Content = title; button. Ask Question. Try adding the following style: <ListBox. If you're putting the ItemsControl in a DockPanel and setting DockPanel. To control content flow in a StackPanel, use the Orientation property. If you want to fill exactly the width of the window, just replace the outer StackPanel by a Grid. 10. [ 1 ] _______ [ 2 ] StackPanel will fill the width,. Working on a windows universal app. When thinking about layout in Avalonia, it is. The code listed in Listing 2 creates a StackPanel dynamically, sets its properties and adds five ellipses. Robert Rossney has a good solution. 6. What is the difference between: Height - Gets or sets the suggested height of the element. The WPF includes a comprehensive suite of derived panel implementations that enable many complex layouts. NET Framework 4. Dock="Top" to the. HeaderTemplate> <DataTemplate> <Stack · I don't think that you can, a StackPanel's width or height (depending on its orientation) is. The basic approachWe are having wpf user control (UserControl. Even if you resized the StackPanel to the correct size, it would not help because a StackPanel does not rearrange or resize it's content items. How would you change it so that: 1) the TextBlock is inside the Button, but left justified with the actual Button width (i. – Gaurav Panwar这会使StackPanel本身变大,但不会更改其子级。. You can control horizontal alignment by using the HorizontalAlignment property. I have a form with two Grid elements in a vertical StackPanel. Although DockPanel can also "stack" child elements, DockPanel and StackPanel do not produce analogous results in some usage scenarios. Here i want to apply background to stack panel. Stretching not applying in a WPF templated Button. The problem is that when I set the background of the UserControl, the color only goes down as far as the content. Visibility = Visibility. An asterisk uses the current width or height of an element and divides by the value associated with the asterisk and when a Window or Page is resized, the actual size. This is how you specify auto sizing behavior in code. hope that helps. Introduction. 22. When I set the stackpanel to Visibility. Setting VerticalAlignment and HorizontalAlignment to Stretch, or leaving it out since it’s the default, will make the container fill the grid, which is what you want. Here is some xaml that displays a Stackpanel containing two Borders side by side. Appendix C: Previous Attempt 3. sample xaml. 0 wpf grid and stackpanel fill. The StackPanel is a fundamental part of many basic app layouts, allowing you to stack elements vertically or horizontally. a circle with a cross at the bottom. <StackPanel Orientation="Horizontal"> Another thing you will likely notice is that the StackPanel stretches its child control by default. I have my own control which derives from StackPanel. Nov 2, 2015 at 23:52. For an example, see the Example: Paint an Object with a Visual section that follows. The key here is to bind to ActualHeight of the other StackPanel. Row="1" attached property for child element if you already add it for parent, the Viewbox in following code fill entire cell but image maybe fill part of the. I'm really new to WPF and I am trying to make an app that will display Word,PDF, and Excel files in it. If you want a grid for the entire screen, you need to put your grid as your first container and set its constraints as shown above. Viewed 18k times. StackPanel. The built in StackPanel control has always been frustrating to use. I want the ListBox to stretch vertically by anchoring to the bottom of the window. I have tried all 3 as the containiner for the StackPanel, but the height will not propertly adjust to fill it. This is the correct answer. So as I understand it the problem is that you want to lay out controls horizontally in a StackPanel and align to the top, but have the text in each control line up. 私は単に左側にテキストを流し、右側にヘルプボックスを入れたいだけです。. ただし、一部のパネルでは引き伸ばしが無効になります。例えば、横方向配置のStackPanel (Orientation= Horizontal)ではHorizontalAlignmentがLeft指定のように動作しますし、Canvasでも無視されます。これは各種パネルのレイアウトの特徴を考えれば自然なことだと理解. I have checked that all of the Heights and Widths are set to Auto, and Horizontal/VerticalAlignments are set to Stretch, and Horizontal/VerticalContentAlignments are also set to Stretch. Set the container (Grid) to the size of the extents, then place the path in it. The problem was that the style for the tabitem contained a content template that displayed the page through a contentpresenter, inside a horizontal stackpanel. For templates, the Parent of the template eventually will be null. You can either set the Visibility of the "Overlay" in code or use a DataTrigger. <UniformGrid Margin="10" Rows="1" HorizontalAlignment="Right" VerticalAlignment="Bottom. 17. StackPanel childs auto resize. Improve this answer. By default, DockPanel has its. The mouse-over should change the style of SP2 to Opacity:100. 36. So I have: 1) MainWindow with a ContentPresenter like this:2. 0 Grid { property int orientation: Qt. UPDATE >>>. If you want the StackPanel to fill at least the whole with, you can bind the MinWidth to its parent ActualWidth: <StackPanel. In this section, we’ll take a look at the different layout properties you can find at PoshGUI along with their functionalities. 1. ItemsPanel> <ItemsPanelTemplate> <UniformGrid Rows="1" /> </ItemsPanelTemplate> </ItemsControl. Here are some that do not resize their contents (I'm guessing that you are using one or more of these): StackPanel WrapPanel Canvas TabControl Here are some that do resize their contents: Grid UniformGrid DockPanelWith the following CSS. <DockPanel LastChildFill="True"> <StackPanel DockPanel. There may be 100 items in the left scrollviewer, so I can't have that item controlling the height. ColumnDefinitions> <ColumnDefinition. Are you new to WPF and confused about using grid and stack panel? If you answered yes, then you are at the right place. VerticalScrollBarVisibility to "Disabled" since the "Hidden" value gives the content infinite space in the vertical direction, that's all. to force the contents of a control to stretch horizontally. Width = 50; realImage. However, I am trying to bind the height of a StackPanel to its containing Grid. I would recommend using DockPanel as the root control for your UserControl so that you could get the behavior you are looking for in its Child Controls. NET MAUI) StackLayout organizes child views in a one-dimensional stack, either horizontally or vertically. Thanks Ross, I actually managed to get something very close using a RelativeSource, though I used 'FindAncestor' and 'Width' but I'll adopt your suggestion. I'm currently using a grid designed to fill a rectangular shape which is wider than it is tall. Therefore, simply replace it with a Grid, give the majority of the space to the inner StackPanel and then the Frame will stick to the bottom. Basically, I don't quite understand how this works in WPF. On elements in the DataTemplate which do not automatically stretch to full width like the Grid does for example, you have to additionally set HorizontalAlignment="Stretch". e. You may need to give your StackPanel a background color for it to receive mouse events. I ended up slightly modifying the DockPanel that comes with the Silverlight Toolkit, and it seems to work. The MainWindow has a StackPanel included. I understand that a StackPanel automatically resizes to fit its elements but I would like to bind it to the Grid so that it does not do this. Sorted by: 88. > </DataGrid>. Silverlight is a little more restricted, owing to its need to keep the runtime install as light as possible, and supports only Canvas, Grid, and StackPanel. When i understand your question right, you want that the full space is yellow and the stackpanel with buttons is centered in the middle. }" Path="ActualWidth"/>. The default orientation is Vertical. This is explained more here. Some of these vertical stacks have more or less elements in them then the ones next to them. ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter. But it's just a hack, not a real solution. 3. <ContentControl Content=" {Binding Path=ChildView}" Margin="10" />. Name = title; button. How to stretch a Rectangle inside a Button? 0. private void OnUIReady(object sender, System. There is no way to stop this besides doing a binding as you describe or setting an absolute height. WPF is all about using containers to control the layout. The rectangles expand to fill the entire width of the StackPanel. Remove the StackPanel and you probably will get what you're looking for. Similarly for the height. Container controls like Grid and RelativePanel automatically scale to the full available size of their parent, while others like StackPanel only grow to the minimal size needed for their child elements. The Parent property is the logical parent, which is different. ItemContainerStyle. With a StackPanel you just follow the nesting, this is easier and less messy than a grid. I have set the ContentPresenter or RebateView with a specific Height and the dockin stretched perfectly. I want to strech all Grids so they fill out the whole screen. Yes, Parent is not supported in WPF project, it's for silverlight. So, I am trying to develop app in WPF (again). Having layout only in XAML would have been more elegant, but sometimes C# code is the only way. Try setting your DataGrid's HorizontalAlignment=Stretch and VerticalScrollBarVisibility=Auto. –12. ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter. Sorted by: 4. Unlike percentage, an asterisk does not have a maximum limit of 100. The same applies for HorizontalAlignment. The problem is when the user input the number squares, the grid do not fill the height of its container. I think by setting HorizontalAligment to Center on the StackPanel you are overriding the behavior of the DockPanel to fill the whole space with the StackPanel. The built in StackPanel control has always been frustrating to use. I can see its size in the designer when I select that panel in the XAML. Since this is not parent of TextBox and TextBlock so it must have a Name to bind with its Actualwidth --> <Grid x:Name="WidthRestrictorGrid" Grid. Set can content scroll to true. Remove the stackpanel. If there are only three, the height of the entire grid should be short and the content in the left scrollviewer should scroll. Very strange. 2. Who said anything about stretching buttons. In WinForms I would just set ListView. I am trying to get a scroll bar to be placed on a stack panel. I am attempting to write a simple WPF learning project which creates a set of buttons inside a resizeable main window. private void CreateDynamicWrapPanel () {. EventArgs e) { LinePane. NET Core WPF Applications – Check out this blog post for a practical example of using Twilio Lookup in a WPF application to obtain phone number information. Try something like this : <Grid x:Name = "grdListBoxTest"> <ListBox x:Name="lstBoxTest" MaxHeight=" {Binding ElementName=grdListBoxTest, Path=ActualHeight}"> <!--. Bind the ItemsSource property of this control to a list of objects you want, here a list of users you've fetched from the database. Some Elements do not have Child-Elemenst like a TextBlock. <Setter Property="Template">. I hope this helps. Is it possible to have a <StackPanel> or labels (or buttons, whatever) going horizontally across it's parent control (e. In Avalonia Panel is a usable control that has the same layout behavior as a Grid with no rows/columns, but with a lighter runtime footprint. By default, the DataGrid's HorizontalAlignment value is set to "Stretch" (as well as VerticalAlignment) that means to stretch the horizontal/vertical content size to fit the parent. Each of them should be 50% of the device's height. The Orientation property can be used to control content flow. oh and in particular, star-sizing can only be done on either the ColumnDefinition. The problem is that you have the images within a canvas. If you want something to stretch consider using a DockPanel (with LastChildFill = true) or a Grid. We added the reference of "Child. 106-84 seems to be the height of the GroupBox header plus the internal border size. At runtime, the grid refused to fill the entire tabitem area, as seen in the screenshots below. . Source Code. I want the container to resize. AllowInfiniteGridSize static property to True, but in that case, the grid will run slowly. I got it figured out. its only strech as textblock content. Panel is the base class for all elements that provide layout support in Windows Presentation Foundation (WPF). <Grid> <test:MyUserControl HorizontalAlignment="Left" VerticalAlignment="Center"/> </Grid>. ItemsPanel are: <StackPanel Orientation="Horizontal"></StackPanel>. Is it possible to have a <StackPanel> or labels (or buttons, whatever) going horizontally across it's parent control (e. The default setting for a grid's row definition height is "*", which says to distribute all of the remaining space among all the rows with that setting. StackPanel height exceed parent Grid height. Thanks Ross, I actually managed to get something very close using a RelativeSource, though I used 'FindAncestor' and 'Width' but I'll adopt your suggestion instead. 13. xamlbased on your code it seems like you want to perform a horizontal scroll by the mouse wheel. You try something like to set the textbox to the width of the parent and use a margin for your subtraction <TextBox HorizontalAlignment="Stretch" Margin="0,0,20,0" Please sign in to rate this answer. StackPanel height exceed parent Grid height. Footer --> <Grid Grid. Stretching of WPF StackPanel. Binding. Vertical: This is the default orientation for StackPanel where the child items are placed vertically one after another from top to bottom. Any element that can have child elements can treat the Stretch value for HorizontalAlignment and. If your items are wider than the ListBox, the other answers here won't help: the items in the ItemTemplate remain wider than the ListBox. I am using a DevExpress FlowLayoutControl and I have a grid inside of it and am not able to get it to fill to the parent size of the. . Window) and have it fill out all the space allowed? For example if I had 3 controls. This controls the space between the text and the button borders. Dock="top">, which effectively "docks" the StackPanel (section) against the top of the DockPanel (overarching container). Row="1"). You can also make the orientation of a wrap panel vertical so that objects flow from top-to-bottom, left-to-right. Column="1" Grid. It stacks its child elements below or beside each other, dependening on its orientation. It currently just sizes to the height of the controls in the StackPanel (the Add and Remove buttons), and resizes to accomodate items that are added. 4. Its children implicitly dock to the left and the last one will "fill" the remaining space. 0. There are two ways to specify the Visual content of a VisualBrush. 19. The larger ellipse with text has the mouse over. When you have a TextBlock that has a lot of text, it is impossible to wrap that text without setting an explicit width. Controls. In WPF, I am having a heck of a time trying to get a grid to size properly. To accomplish this, create a 6x7 Grid and set both the height and width to *. don't use a StackPanel for layout purposes. How would you change it so that: 1) the TextBlock is inside the Button, but left justified with the actual Button width (i. I'm attempting to stretch the height of a ListBox 100% of the height of the parent grid (i. /> <StackPanel>. It will allow it's children to get how much ever space they desire. 1. This is exactly what happens when you set Orientation="Vertical". Footer --> <Grid Grid. The WPF equivalent of WinForms' DockStyle. – TheOne.