Monday, 21 October 2013

Horizontal and Vertical Alignment in W P F (Top, Bottom, Right, Left)

Horizontal and Vertical Alignment in W P F (Top, Bottom, Right, Left)

<!—Two namesape of WPF -->

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="520">

<!--Create Layout Grid Panel-->
<Grid>
<!—Create Row in  Grid Panel-->

<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
</Grid.RowDefinitions>

<!—Create Column in  Grid Panel-->

<Grid.ColumnDefinitions>
<ColumnDefinition Width="125" />
<ColumnDefinition Width="125" />
<ColumnDefinition Width="125" />
<ColumnDefinition Width="125" />
</Grid.ColumnDefinitions>

<!—Add Button in Grid (0,0) With Vertical=Top Hor -->

<Button Grid.Row="0" Grid.Column="0" Content="Button" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Grid.Row="0" Grid.Column="1" Content="Button" VerticalAlignment="Top" HorizontalAlignment="center"/>
<Button Grid.Row="0" Grid.Column="2" Content="Button" VerticalAlignment="Top" HorizontalAlignment="Right"/>
<Button Grid.Row="0" Grid.Column="3" Content="Button" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>

<Button Grid.Row="1" Grid.Column="0" Content="Button" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<Button Grid.Row="1" Grid.Column="1" Content="Button" VerticalAlignment="Center" HorizontalAlignment="center"/>
<Button Grid.Row="1" Grid.Column="2" Content="Button" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<Button Grid.Row="1" Grid.Column="3" Content="Button" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>

<Button Grid.Row="2" Grid.Column="0" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
<Button Grid.Row="2" Grid.Column="1" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="center"/>
<Button Grid.Row="2" Grid.Column="2" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
<Button Grid.Row="2" Grid.Column="3" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>

<Button Grid.Row="3" Grid.Column="0" Content="Button" VerticalAlignment="Stretch" HorizontalAlignment="Left"/>
<Button Grid.Row="3" Grid.Column="1" Content="Button" VerticalAlignment="Stretch" HorizontalAlignment="center"/>
<Button Grid.Row="3" Grid.Column="2" Content="Button" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<Button Grid.Row="3" Grid.Column="3" Content="Button" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>

</Grid>
</Window>


0 comments:

Post a Comment