65.棋盘 C#例子 WPF例子

发布于:2025-02-10 ⋅ 阅读:(43) ⋅ 点赞:(0)

这是一个不具备任何功能的UI设计,使用矩形和边界和文字块。通过这些可以自由的创建不同显示效果的内容。

棋盘展示:

代码展示:

<Window x:Class="棋盘设计.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:棋盘设计"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Border Margin="10" Grid.Column="1" Grid.Row="1" Grid.RowSpan="4" Grid.ColumnSpan="4" Background="LightBlue">
            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="此片区域覆盖显示为蓝色" FontSize="24"/>
        </Border>
        
        <Rectangle Grid.Column="1" Grid.Row="0" Fill="Red" Margin="0,10,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="0" Fill="Red" Margin="10,10,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="1" Fill="Red" Margin="10,0,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="2" Fill="Red" Margin="10,0,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="3" Fill="Red" Margin="10,0,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="4" Fill="Red" Margin="10,0,0,0"/>
        <Rectangle Grid.Column="0" Grid.Row="5" Fill="Red" Margin="10,0,0,10"/>
        <Rectangle Grid.Column="1" Grid.Row="5" Fill="Red" Margin="0,0,0,10"/>
        <Rectangle Grid.Column="2" Grid.Row="5" Fill="LightGreen" Margin="0,0,0,10" Stroke="Yellow"/>
        <Rectangle Grid.Column="3" Grid.Row="5" Fill="LightGreen" Margin="0,0,0,10" Stroke="Yellow"/>
        <Rectangle Grid.Column="4" Grid.Row="5" Fill="LightGreen" Margin="0,0,0,10" Stroke="Yellow"/>
        <Rectangle Grid.Column="5" Grid.Row="5" Fill="LightGreen" Margin="0,0,10,10" Stroke="Yellow"/>
        <Rectangle Grid.Column="5" Grid.Row="4" Fill="LightGreen" Margin="0,0,10,0" Stroke="Yellow"/>
        <Border Grid.Column="5" Grid.Row="0" Background="WhiteSmoke" Margin="5">
            <TextBlock Text="棋盘显示" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Border>
    </Grid>
</Window>


网站公告

今日签到

点亮在社区的每一天
去签到