WPF基础入门2 - WPF窗口类和垂直布局面板基本使用
新建一个wpf工程;编辑xaml代码如下;
<Window x:Class="test1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="test1" Height="300" Width="300"
>
<Grid>
<StackPanel>
<Label x:Name="lblhello">欢迎光临WPF</Label>
<Button Name="btn1" >按钮1</Button>
<Button Name="btn2" >按钮2</Button>
<Button Name="btn3" >按钮3</Button>
</StackPanel>
</Grid>
</Window>
自定义的窗体均继承System.Windows.Window类;新建一个窗体,类名默认为Window1;可在xaml中编辑窗口标题,高和宽;
StackPanel是垂直布局面板;控件放于其中,自动按垂直逐个放置;如不指定具体属性,每个控件默认占满StackPanel宽度;
运行程序;结果如下;
还没有评论,来说两句吧...