WPFでの画面のレイアウト方法

WPFでの画面のレイアウト方法をまとめる

基本 Window 1つで、Page で表示内容を変更するのがよさそう?
NavigationWindow や Frame が画面遷移が楽そう。

Grid
DockPanel
StackPanel
WrapPanel

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <WrapPanel Orientation="Vertical" HorizontalAlignment="Center" Grid.Column="0">
            <Button x:Name="button1" Content="Button1" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button2" Content="Button2" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button3" Content="Button3" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button4" Content="Button4" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button5" Content="Button5" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button6" Content="Button6" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button7" Content="Button7" Width="150" Height="60" Margin="20"/>
            <Button x:Name="button8" Content="Button8" Width="150" Height="60" Margin="20"/>
        </WrapPanel>
        <StackPanel Grid.Column="1">
            <Button x:Name="button" Content="Button"/>
        </StackPanel>
    </Grid>
</Window>

Tags