XAML 实例演示之一
XAML 系列文章为学习笔记,这是我今年春节期间安排的学习任务。
StackPanel、Menu、Expander 元素的演示
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="Welcome" Height="300" Width="300"
>
<StackPanel
Name="HelloWorldGrid"
Background="AntiqueWhite"
>
<Menu
Height="21" Margin="0,0,0,0">
<MenuItem Header="开源博客平台">
<MenuItem Header="ASP.NET" />
<MenuItem Header="C#" />
</MenuItem>
<MenuItem Header="开源论坛系统">
<MenuItem Header="Version 1.0" />
<MenuItem Header="Version 2.0" />
<MenuItem Header="Version 3.0" />
<MenuItem Header="Version 3.5" />
</MenuItem>
</Menu>
<Label
Content="Welcome to http://forum.EntLib.com"
FontFamily="Verdana"
FontSize="12" Padding="20"
/>
<Expander Height="50"
Name="MyExpander"
VerticalAlignment="Bottom"
Content="When you click on an expander it shows its content."
/>
</StackPanel>
</Window>
FlowDocument 元素的演示:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="Welcome">
<FlowDocument>
<Paragraph FontSize="28" Foreground="Red">
Introducing XAML: A Declarative Way to Create Windows UIs
</Paragraph>
<Paragraph>
Before the appearance of .NET 3.0, web applications were written with "markup
languages" such as HTML and Windows applications were not. We may have
dragged controls onto forms, but the creation of the controls and their
properties was managed by the development environment, or you instantiated
them programmatically at runtime.
</Paragraph>
</FlowDocument>
</Window>
在我们的范例中,DockPanel 用来从左到右布局元素(尽管可以通过设置属性来靠边-left, right, top 和 bottom),然而 StackPanel 用来从上到下堆放元素。
相关链接: