StackPanel in WPF - XAML
Stackpanel XAML C#
The StackPanel in XAML is a simple and useful layout panel. The stack panel allows you to stack objects one on top of the other, depending on its orientation. It stretches it content in one direction, allowing you to stack item after item on top of each other.
It is very useful to create any kind of lists. All WPF ItemsControls like ComboBox, ListBox or Menu use a StackPanel as their internal layout panel. The following wpf stackpanel example demonstrates how to work with stackpanel in xaml.
Related Articles
C# Stackpanel Orientation
In wpf stackpanel layout you can adjust the Orientation of content within stackpanel object and also you can adjust the HorizontalAlignment and VerticalAlignment of child content using the value of the Orientation, HorizontalAlignment, and VerticalAlignment properties of a StackPanel.
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
stackpanel wpf |
<Window x:Class="LayoutWithStackPanel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Stackpanel in wpf" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Your First Name:" Margin="5" />
<TextBox Width="80"
Height="Auto"
Margin="5"/>
<TextBlock Text="Your Last Name:" Margin="5" />
<TextBox Width="80"
Height="Auto"
Margin="5"/>
</StackPanel>
</Grid>
</Window>
I hope you will enjoy the development tips while programming with WPF in C#. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.
Also If you like this article, don't forget to share this article with your friends and colleagues.
Also If you like this article, don't forget to share this article with your friends and colleagues.
StackPanel in WPF - XAML
Reviewed by Ravi Kumar
on
12:21 AM
Rating:
No comments: