右键新建项WPF
修改为Window
编写代码
<Window x:Class="StudentRevit.AdjustPepe"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StudentRevit"
mc:Ignorable="d" Height="300" Width="400">
<Grid>
<!-- 定义grid 的行-->
<Grid.RowDefinitions>
<!--grid的行数,RowDefinition代表行的个数-->
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<!-- 定义grid 的列 -->
<!--<Grid.ColumnDefinitions>
--><!-- grid的列数,ColumnDefinition代表列的个数 --><!--
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>-->
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock Text="风管宽" Width="70" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" FontSize="20"></TextBlock>
<TextBox x:Name="widthTextBox" Width="120" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10"></TextBox>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="80,0,80,0">
<!--Grid.Row代表,Button在哪一行,从0开始算-->
<Button Width="80" Height="30" Content="确认" Grid.Row="1" Margin="10"></Button>
<Button Width="80" Height="30" Content="取消" Grid.Row="1" Margin="10"></Button>
</StackPanel>
</Grid>
</Window>
为按钮添加事件
验证