您的位置:首页 > 其它

WPF实例学习(A-01)

2007-10-19 17:04 357 查看
代码所在位置:WPFSamples"Intro"QuickStart1

这个例子,可以认为是WPF应用的Hello Worldchen 程序

目录下面一共有两个XAML文件MyApp.xaml和Page1.xaml

XAML是XML的一个子集,如果熟悉XML或者HTML的人会很容易看懂,不熟悉的也能很容易看懂J

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>

MyApp.xaml 文件中

使用[Application]标签定义了一个应用

通过 StartupUri="Page1.xaml"

定义了一个应用(Application)的启动页面为Page1.xaml

下面再看 Page1.xaml

Page1.xaml

<Page

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

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

>

<StackPanel

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

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

<TextBlock>

Hello, World!

</TextBlock>

</StackPanel>

</Page>

Page1.xaml 文件中使用 [Page]标签定义页面。

然后定义了页面的一个布局(LayOut)为 [StackPanel],当然,XAML中还有许多其他类型的布局,在以后会逐一介绍的,大家先不用着急。

接着,在[StackPanel]的内部定义了一个 [TextBlock]这样在页面上就会显示一个TextBlock,其内容为Hello, World!

程序编译之后的运行截图如下:


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