您可以创建自己的UserControl,其中包含ProgressRing和用于消息的TextBlock,以下是示例:
<UserControl
x:Class="YourNamespace.ProgressRingWithText"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:YourNamespace"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
x:Name="uc">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ProgressRing IsActive="{Binding IsActive, ElementName=uc}"/>
<TextBlock Text="{Binding Text, ElementName=uc}" HorizontalAlignment="Center"/>
</Grid>
还有C#:
public sealed partial class ProgressRingWithText : UserControl
{
public bool IsActive
{
get { return (bool)GetValue(IsActiveProperty); }
set { SetValue(IsActiveProperty, value); }
}
public static readonly DependencyProperty IsActiveProperty =
DependencyProperty.Register("IsActive", typeof(bool), typeof(ProgressRingWithText), new PropertyMetadata(false));
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(ProgressRingWithText), new PropertyMetadata("Loading..."));
public ProgressRingWithText()
{
this.InitializeComponent();
}
}
当你将这些属性添加到你的窗口/页面时,你可以引用它们。
你甚至可以更进一步使用一个布尔转可见性转换器,将IsActive属性转换为Visibility,以改变TextBlock的可见性。
当然,这是一个非常简单的用户界面,但你可以尝试一下,看看它是否适合你。