C# WPF编程基础

XAML文件内容

cs 复制代码
<Window x:Class="Wpf_demo1.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:Wpf_demo1"
        mc:Ignorable="d"
        Title="我爱学编程" Height="450" Width="800">
    <!--x:Class="Wpf_demo1.MainWindow"这里的MainWindow名称与.xaml.cs上的public partial class 名称相同-->
    <!--上述区域代表非客户区,正常来说只能修改Title的属性-->
    <!--<Grid>
        -->
    <!--Grid区域代表客户区-->
    <!--
        <Button Width="122" HorizontalAlignment="Right" Margin="0,70,606,244"/>
        <Button Width="122" HorizontalAlignment="Left" Margin="476,217,0,97"/>
    </Grid>-->
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions><!--将整个页面分成4行-->
            <RowDefinition Height="20"/>
            <RowDefinition Height="20"/>
            <RowDefinition/>
            <RowDefinition Height="20" />
        </Grid.RowDefinitions>
        
        <!--定义了第一行的内容-->
        <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
            <Button Height="20" Width="70" Content="文件"/>
            <Button Height="20" Width="70" Content="编辑"/>
            <Button Height="20" Width="70" Content="查看"/>
            <Button Height="20" Width="70" Content="外观"/>
            <Button Height="20" Width="70" Content="设置"/>
            <Button Height="20" Width="70" Content="帮助"/>
        </StackPanel>
        
            <!--定义了第二行的内容-->
        <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
            <Button Height="20" Width="70" Content="1"/>
            <Button Height="20" Width="70" Content="2"/>
            <Button Height="20" Width="70" Content="3"/>
            <Button Height="20" Width="70" Content="4"/>
            <Button Height="20" Width="70" Content="5"/>
            <Button Height="20" Width="70" Content="6"/>
        </StackPanel>
        <!--定义第三行第一列的内容-->
        <Grid Grid.Row="2" Grid.Column="0" Background="Aqua">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="70" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <StackPanel>
                <Button Height="20" Content="1"/>
                <Button Height="20" Content="3"/>
                <Button Height="20" Content="5"/>
                <Button Height="20" Content="7"/>
                <Button Height="20" Content="9"/>
            </StackPanel>
            <!--定义第三行第二列为输入文本-->
            <TextBox Grid.Row="0" Grid.Column="1" TextWrapping="Wrap"/>

        </Grid>
        <!--定义最后一行的内容-->
        <Grid Grid.Row="3" Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <Button Grid.Row="0" Grid.Column="0" Content="行"/>
            <Button Grid.Row="0" Grid.Column="1" Content="列"/>
            <Button Grid.Row="0" Grid.Column="2" Content="字符"/>
            <Button Grid.Row="0" Grid.Column="3" Content="求值"/>
            <Button Grid.Row="0" Grid.Column="4" Content="选定"/>
            <Button Grid.Row="0" Grid.Column="5" Content="选行"/>
            <Button Grid.Row="0" Grid.Column="6" Content="匹配"/>

        </Grid>



    </Grid>

</Window>
相关推荐
uppp»19 分钟前
深入理解 Java 反射机制:获取类信息与动态操作
java·开发语言
玩电脑的辣条哥2 小时前
Python如何播放本地音乐并在web页面播放
开发语言·前端·python
ll7788115 小时前
LeetCode每日精进:20.有效的括号
c语言·开发语言·算法·leetcode·职场和发展
Jackson@ML7 小时前
Python数据可视化简介
开发语言·python·数据可视化
积跬步---行千里7 小时前
记录一次WPF程序进程挂起问题
mongodb·wpf
赵琳琅7 小时前
Java语言的云计算
开发语言·后端·golang
lly2024067 小时前
jQuery 杂项方法
开发语言
赵琳琅7 小时前
MDX语言的安全开发
开发语言·后端·golang
开开又心心的学嵌入式7 小时前
C语言——指针进阶应用
c语言·开发语言
开开又心心的学嵌入式7 小时前
C语言——指针基础知识
c语言·开发语言