WPF实例学习(A-01)

代码所在位置:WPFSamples"Intro"QuickStart1

 

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

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

 

XAMLXML的一个子集,如果熟悉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">

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

导航