Silverlight学习笔记四BusyIndicator控件(进度条)
BusyIndicator是SilverLight中的进度条控件。下面是一个例子
1.BusyIndicatorSample.xaml
<UserControl x:Class="Silverlight.Common.View.BusyIndicatorSample"
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:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" Loaded="UserControl_Loaded">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<toolkit:HeaderedContentControl Grid.Column="0" Width="160" Header="数据加载中---">
<toolkit:BusyIndicator x:Name="BusyIndicator2" IsBusy="True" DisplayAfter="0"
BusyContent="数据加载中---"></toolkit:BusyIndicator>
</toolkit:HeaderedContentControl>
<toolkit:HeaderedContentControl Grid.Column="1" Header="数据下载中---">
<toolkit:BusyIndicator x:Name="BusyIndicator3" IsBusy="True" DisplayAfter="0">
<toolkit:BusyIndicator.BusyContentTemplate>
<DataTemplate>
<StackPanel Margin="4" >
<TextBlock Text="数据下载中---" FontWeight="Bold" HorizontalAlignment="Center"/>
<StackPanel Margin="4">
<TextBlock Text="已下载 99%..."/>
<ProgressBar Value="99" Height="15"/>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="停止" x:Name="btnStop" HorizontalAlignment="Right" Margin="0 0 2 0"/>
<Button Grid.Column="1" Content="取消" x:Name="btnCancel" HorizontalAlignment="Left" Margin="2 0 0 0"/>
</Grid>
</StackPanel>
</DataTemplate>
</toolkit:BusyIndicator.BusyContentTemplate>
<toolkit:BusyIndicator.ProgressBarStyle>
<Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</toolkit:BusyIndicator.ProgressBarStyle>
</toolkit:BusyIndicator>
</toolkit:HeaderedContentControl>
</Grid>
</UserControl>
注:IsBusy属性设置为true才会显示进度。
HeaderedContentControl控件里放其他控件。