WPF布局按钮切换

WPF布局按钮切换,效果和代码如下
在这里插入图片描述

<Window x:Class="LayoutTransitionsDemo.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:LayoutTransitionsDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" Loaded="OnLoad">
    <Grid Background="{StaticResource BgKey}">
        <Grid.RowDefinitions>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Grid Grid.Row="0" Grid.Column="0" Name="ButtonGrid">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Button Grid.Row="0" Grid.Column="0" Click="OnGrid5"
                    AutomationProperties.HelpText="Move all buttons into the five by five (5x5) grid">
                MoveToGrid5
            </Button>
            <Button Grid.Row="1" Grid.Column="0" Click="OnGrid3"
                    AutomationProperties.HelpText="Move all buttons into the three by three (3x3) grid">
                MoveToGrid3
            </Button>
            <Button Grid.Row="2" Grid.Column="0" Click="OnAdvanceClick"
                    AutomationProperties.HelpText="Increase the starting location in the grid by one">
                Grid:Advance
            </Button>
            <Button Grid.Row="3" Grid.Column="0" Click="OnRetreatClick"
                    AutomationProperties.HelpText="Decrease the starting location in the grid by one">
                Grid:Retreat
            </Button>
            <Button Grid.Row="4" Grid.Column="0" Click="OnStackPanel"
                    AutomationProperties.HelpText="Move all buttons into the stack panel">
                MoveToStack
            </Button>
            <Button Grid.Row="5" Grid.Column="0" Click="OnStackVertical"
                    AutomationProperties.HelpText="Set the Stackpanel's orientation to vertical">
                Stack:Vertical
            </Button>
            <Button Grid.Row="6" Grid.Column="0" Click="OnStackHorizontal"
                    AutomationProperties.HelpText="Set the Stackpanel's orientation to horizontal">
                Stack:Horizontal
            </Button>
            <Button Grid.Row="7" Grid.Column="0" Click="OnWrapPanel"
                    AutomationProperties.HelpText="Move all buttons into the wrap panel">
                MoveToWrap
            </Button>
            <Button Grid.Row="8" Grid.Column="0" Click="OnWrapVertical"
                    AutomationProperties.HelpText="Set the wrappanel's orientation to vertical">
                Wrap:Vertical
            </Button>
            <Button Grid.Row="9" Grid.Column="0" Click="OnWrapHorizontal"
                    AutomationProperties.HelpText="Set the wrappanel's orientation to horizontal">
                Wrap:Horizontal
            </Button>
        </Grid>

        <Grid Grid.Row="0" Grid.Column="1" Name="LTLGrid">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
        </Grid>

        <Grid Grid.Row="0" Grid.Column="1" Name="LTLGrid2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
        </Grid>

        <StackPanel Grid.Row="0" Grid.Column="1" Name="LTLStackPanel" />

        <WrapPanel Grid.Row="0" Grid.Column="1" Margin="100" Name="LTLWrapPanel" />

        <Canvas Grid.Row="0" Grid.Column="1" Name="LTLCanvas" />
    </Grid>
</Window>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向着光-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值