您的位置:首页 > 其它

WPF实例学习(A-02)

2007-10-19 17:06 337 查看
MyApp.xaml

<Application

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

StartupUri="Page1.xaml">

</Application>

QuickStart2中的MyApp.xaml文件和QuickStart1一样,没有变化

Page1.xaml

<!--<SnippetSimpleLayout>-->

<StackPanel

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Button HorizontalAlignment="Left"

Width="100"

Margin="10,10,10,10">Button 1</Button>

<Button HorizontalAlignment="Left"

Width="100"

Margin="10,10,10,10">Button 2</Button>

<Button HorizontalAlignment="Left"

Width="100"

Margin="10,10,10,10">Button 3</Button>

</StackPanel>

<!--</SnippetSimpleLayout>-->

下面介绍一下[StackPanel]布局,[StackPanel]可以把内部的元素水平或者垂直的放置。

默认情况下是垂直放置的,如图所示:


500){this.resized=true;this.style.width=500;}">

通过调整[StackPanel]的Orientation属性为Horizontal,可以使内部的控件水平放置

<StackPanel Orientation="Horizontal">

显示效果如下图所示:


500){this.resized=true;this.style.width=500;}">

这个例子中,在[StackPanel]中添加了三个[Button],HorizontalAlignment标签定义了对齐位置为Left,这个例子在一定程度上说明了[StackPanel]的布局方式,从下图的显示结果可以看到


500){this.resized=true;this.style.width=500;}" resized="true">
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: