WPF实例学习(A-02)
2006-07-02 18:23
411 查看
代码所在位置:WPFSamples/Intro/QuickStart2
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]可以把内部的元素水平或者垂直的放置。
默认情况下是垂直放置的,如图所示:
通过调整[StackPanel]的Orientation属性为Horizontal,可以使内部的控件水平放置
<StackPanel Orientation="Horizontal">
显示效果如下图所示:
这个例子中,在[StackPanel]中添加了三个[Button],HorizontalAlignment 标签定义了对齐位置为Left,这个例子在一定程度上说明了[StackPanel]的布局方式,从下图的显示结果可以看到
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]可以把内部的元素水平或者垂直的放置。
默认情况下是垂直放置的,如图所示:
通过调整[StackPanel]的Orientation属性为Horizontal,可以使内部的控件水平放置
<StackPanel Orientation="Horizontal">
显示效果如下图所示:
这个例子中,在[StackPanel]中添加了三个[Button],HorizontalAlignment 标签定义了对齐位置为Left,这个例子在一定程度上说明了[StackPanel]的布局方式,从下图的显示结果可以看到
相关文章推荐
- WPF实例学习(A-02)
- WPF学习笔记 - 如何用WPF创建单实例应用程序
- OGG学习笔记02-单向复制配置实例
- linux 驱动学习笔记02--应用实例:在内核中新增驱动代码目录和子目录
- WPF实例学习(A-03)
- OGG学习笔记02-单向复制配置实例
- [转载] WPF实例学习 (A-01)
- OGG学习笔记02-单向复制配置实例
- WPF实例学习(A-04)
- Laravel5.0学习--02 实例进阶
- WPF学习02:Routed Events
- WPF实例学习(00)
- WPF实例学习(A-04)
- 001-练习02:入门学习Linux常用必会60个命令实例详解
- WPF学习02——XAML编译
- WPF + USB Camera 学习实例
- WPF实例学习(A-05)
- WPF实例学习(A-01)
- WPF学习实例 -- 股票行情查看程序
- WPF实例学习(A-03)