WPF 360°旋转加载(SVG)
WPF 360°旋转加载,如图:

XAML 代码
<UserControl x:Class="Micro.MIM.Styles.Loading"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Micro.MIM.Styles"
mc:Ignorable="d"
d:DesignHeight="32" d:DesignWidth="32">
<UserControl.Resources>
<Storyboard x:Key="waiting" Name="waiting">
<DoubleAnimation Storyboard.TargetName="SpinnerRotate" Storyboard.TargetProperty="(RotateTransform.Angle)" From="0" To="359" Duration="0:0:1.5" RepeatBehavior="Forever" />
</Storyboard>
</UserControl.Resources>
<Grid>
<Path x:Name="path" Width="16" Fill="#9f9fa3" Height="16" Stretch="Fill" RenderTransformOrigin="0.5,0.5" Loaded="Path_Loaded" Data="M72.282353 584.282353C112.202794 584.282353 144.564706 551.920441 144.564706 512 144.564706 472.079559 112.202794 439.717647 72.282353 439.717647 32.361912 439.717647 0 472.079559 0 512 0 551.920441 32.361912 584.282353 72.282353 584.282353ZM951.717647 584.282353C991.638088 584.282353 1024 551.920441 1024 512 1024 472.079559 991.638088 439.717647 951.717647 439.717647 911.797206 439.717647 879.435294 472.079559 879.435294 512 879.435294 551.920441 911.797206 584.282353 951.717647 584.282353ZM439.717647 72.282353C439.717647 112.202794 472.079559 144.564706 512 144.564706 551.920441 144.564706 584.282353 112.202794 584.282353 72.282353 584.282353 32.361912 551.920441 0 512 0 472.079559 0 439.717647 32.361912 439.717647 72.282353ZM439.717647 951.717647C439.717647 991.638088 472.079559 1024 512 1024 551.920441 1024 584.282353 991.638088 584.282353 951.717647 584.282353 911.797206 551.920441 879.435294 512 879.435294 472.079559 879.435294 439.717647 911.797206 439.717647 951.717647ZM145.191613 247.414297C173.419628 275.642311 219.186282 275.642311 247.414297 247.414297 275.642311 219.186282 275.642311 173.419628 247.414297 145.191613 219.186282 116.963598 173.419628 116.963598 145.191613 145.191613 116.963598 173.419628 116.963598 219.186282 145.191613 247.414297ZM767.046273 869.268957C795.274288 897.496972 841.040943 897.496972 869.268957 869.268957 897.496972 841.040943 897.496972 795.274288 869.268957 767.046273 841.040943 738.818259 795.274288 738.818259 767.046273 767.046273 738.818259 795.274288 738.818259 841.040943 767.046273 869.268957ZM767.046273 145.191613C738.818259 173.419628 738.818259 219.186282 767.046273 247.414297 795.274288 275.642311 841.040943 275.642311 869.268957 247.414297 897.496972 219.186282 897.496972 173.419628 869.268957 145.191613 841.040943 116.963598 795.274288 116.963598 767.046273 145.191613ZM145.191613 767.046273C116.963598 795.274288 116.963598 841.040943 145.191613 869.268957 173.419628 897.496972 219.186282 897.496972 247.414297 869.268957 275.642311 841.040943 275.642311 795.274288 247.414297 767.046273 219.186282 738.818259 173.419628 738.818259 145.191613 767.046273Z">
<Path.RenderTransform>
<RotateTransform x:Name="SpinnerRotate" Angle="0" />
</Path.RenderTransform>
</Path>
</Grid>
</UserControl>
C# 代码
namespace Micro.MIM.Styles
{
/// <summary>
/// Loading.xaml 的交互逻辑
/// </summary>
public partial class Loading : UserControl
{
public Loading()
{
InitializeComponent();
}
private Storyboard story;
private void Path_Loaded(object sender, RoutedEventArgs e)
{
this.story = (base.Resources["waiting"] as Storyboard);
this.story.Begin(this.path, true);
}
public void Stop()
{
base.Dispatcher.BeginInvoke(new Action(() => {
this.story.Pause(this.path);
base.Visibility = System.Windows.Visibility.Collapsed;
}));
}
}
}

浙公网安备 33010602011771号