WPF实例学习(A-02)

 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">

posted on 2007-10-19 17:06  舞舞  阅读(1461)  评论(0编辑  收藏  举报

导航