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>
相关推荐
我是陈泽8 分钟前
一行 Python 代码能实现什么丧心病狂的功能?圣诞树源代码
开发语言·python·程序员·编程·python教程·python学习·python教学
优雅的小武先生19 分钟前
QT中的按钮控件和comboBox控件和spinBox控件无法点击的bug
开发语言·qt·bug
明耀19 分钟前
WPF RadioButton 绑定boolean值
c#·wpf
虽千万人 吾往矣25 分钟前
golang gorm
开发语言·数据库·后端·tcp/ip·golang
创作小达人27 分钟前
家政服务|基于springBoot的家政服务平台设计与实现(附项目源码+论文+数据库)
开发语言·python
郭二哈30 分钟前
C++——list
开发语言·c++·list
杨荧31 分钟前
【JAVA开源】基于Vue和SpringBoot的洗衣店订单管理系统
java·开发语言·vue.js·spring boot·spring cloud·开源
ZPC821038 分钟前
Python使用matplotlib绘制图形大全(曲线图、条形图、饼图等)
开发语言·python·matplotlib
镜花照无眠39 分钟前
Python爬虫使用实例-mdrama
开发语言·爬虫·python
aaasssdddd961 小时前
python和c
c语言·开发语言·python