首页 / 软件开发 / Silverlight / 稳扎稳打Silverlight(42) - 4.0控件之Viewbox, RichTextBox
稳扎稳打Silverlight(42) - 4.0控件之Viewbox, RichTextBox2010-11-01 博客园 webabcd介绍 4.0 控件一览:* Viewbox - 一个容器控件,其内只能有一个子元素。Viewbox 可以决定其内的子元素如何拉伸、缩放、对齐* RichTextBox - 编辑器。用于显示或编辑文本、超链、图片、UI元素等在线DEMOhttp://www.cnblogs.com/webabcd/archive/2010/08/09/1795417.html示例1、Viewbox 的 DemoViewboxDemo.xaml代码<navigation:Page x:Class="Silverlight40.Control.ViewboxDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
Title="ViewboxDemo Page">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Background="AntiqueWhite" HorizontalAlignment="Left">
<!-- 用于演示 Viewbox.Stretch 属性 -->
<StackPanel Margin="5" Width="200">
<TextBlock Text="Stretch" />
<Button Name="btn1" Click="stretchNone" Content="None" />
<Button Name="btn2" Click="stretchFill" Content="Fill" />
<Button Name="btn3" Click="stretchUniform" Content="Uniform" />
<Button Name="btn4" Click="stretchUniformToFill" Content="UniformToFill" />
</StackPanel>
<!-- 用于演示 Viewbox.StretchDirection 属性 -->
<StackPanel Margin="5" Width="200">
<TextBlock Text="StretchDirection" />
<Button Name="btn5" Click="stretchDirectionUpOnly" Content="UpOnly" />
<Button Name="btn6" Click="stretchDirectionDownOnly" Content="DownOnly" />
<Button Name="btn7" Click="stretchDirectionBoth" Content="Both" />
</StackPanel>
<!-- 用于演示 Viewbox.HorizontalAlignment 属性 -->
<StackPanel Margin="5" Width="200">
<TextBlock Text="HorizontalAlignment" />
<Button Name="btn8" Click="horizontalAlignmentCenter" Content="Center" />
<Button Name="btn9" Click="horizontalAlignmentLeft" Content="Left" />
<Button Name="btn10" Click="horizontalAlignmentRight" Content="Right" />
<Button Name="btn11" Click="horizontalAlignmentStretch" Content="Stretch" />
</StackPanel>
<!-- 用于演示 Viewbox.VerticalAlignment 属性 -->
<StackPanel Margin="5" Width="200">
<TextBlock Text="VerticalAlignment" />
<Button Name="btn12" Click="verticalAlignmentCenter" Content="Center" />
<Button Name="btn13" Click="verticalAlignmentTop" Content="Top" />
<Button Name="btn14" Click="verticalAlignmentBottom" Content="Bottom" />
<Button Name="btn15" Click="verticalAlignmentStretch" Content="Stretch" />
</StackPanel>
<!-- 用于显示当前 Viewbox 的 Stretch 值,StretchDirection 值,HorizontalAlignment 值,VerticalAlignment 值 -->
<StackPanel Margin="5">
<TextBlock Name="lblMsg" />
</StackPanel>
<!-- 用于演示 Viewbox 的各种效果 -->
<StackPanel Width="500" Height="300" Background="Black">
<Viewbox Name="viewbox" Width="500" Height="300">
<!-- 注:Viewbox 内只能有一个子元素 -->
<Image Source="/Resource/Logo.jpg" />
</Viewbox>
</StackPanel>
</StackPanel>
</Grid>
</navigation:Page>