相关文章推荐
睡不着的豌豆  ·  Prohibited package ...·  1 年前    · 
俊秀的松球  ·  jpa批量删除-掘金·  1 年前    · 
忧郁的麻辣香锅  ·  研究报告 | ...·  1 年前    · 
激动的抽屉  ·  Matlab中插值函数 - ...·  1 年前    · 
<UserControl x:Class="K.Controls.Controls.LoadingImage"
             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:K.Controls.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
        <Image Width="32" Height="32" Source="/K.Controls;component/Images/Black/ic_loading2.png">
            <Image.RenderTransform>
                <RotateTransform x:Name="imgTransform"
                                     CenterX="15"
                                     CenterY="15"
                                     Angle="90"/>
            </Image.RenderTransform>
            <Image.Triggers>
                <EventTrigger RoutedEvent="UserControl.Loaded">
                    <BeginStoryboard>
                        <Storyboard RepeatBehavior="Forever" SpeedRatio="0.7">
                            <DoubleAnimation
                                Storyboard.TargetName="imgTransform"
                                Storyboard.TargetProperty="Angle" From="0" To="360"
                                Duration="0:0:1"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Image.Triggers>
        </Image>
    </StackPanel>
</UserControl>

在需用使用loading的页面xaml文件中,增加引用:

<controls:LoadingImage HorizontalAlignment="Center" VerticalAlignment="Center"/>

controls表示引用其他类库文件,导入到文件所取得别名,如下所示:

xmlns:controls="clr-namespace:K.Controls.Controls;assembly=K.Controls"