zoukankan      html  css  js  c++  java
  • WPF 等待加载效果

    <UserControl x:Class="CustomControl.LoadingWait"
                 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:CustomControl"
                 mc:Ignorable="d" 
                 IsVisibleChanged="HandleVisibleChanged">
        <UserControl.Background>
            <SolidColorBrush Color="Transparent"/>
        </UserControl.Background>
        <UserControl.Resources>
            <SolidColorBrush Color="#329FEE" x:Key="CirclesColor" />
            <!--<SolidColorBrush Color="Black" x:Key="BackgroundColor" Opacity=".20" />-->
        </UserControl.Resources>
        <Viewbox Width="50" Height="50"  
                HorizontalAlignment="Center"  
                VerticalAlignment="Center">
            <Grid x:Name="LayoutRoot"   
                    Background="Transparent"  
                    ToolTip="Please wait...."  
                    HorizontalAlignment="Center"  
                    VerticalAlignment="Center">
                <TextBlock Text="Loading..."  HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Foreground="#FFE3953D" FontWeight="Bold" />
                <Canvas RenderTransformOrigin="0.5,0.5"  
                        HorizontalAlignment="Center"  
                        VerticalAlignment="Center" Width="120"  
                        Height="120" Loaded="HandleLoaded"  
                        Unloaded="HandleUnloaded"  >
                    <Ellipse x:Name="C0" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="1.0"/>
                    <Ellipse x:Name="C1" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.9"/>
                    <Ellipse x:Name="C2" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.8"/>
                    <Ellipse x:Name="C3" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.7"/>
                    <Ellipse x:Name="C4" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.6"/>
                    <Ellipse x:Name="C5" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.5"/>
                    <Ellipse x:Name="C6" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.4"/>
                    <Ellipse x:Name="C7" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.3"/>
                    <Ellipse x:Name="C8" Width="20" Height="20"  
                             Canvas.Left="0"  
                             Canvas.Top="0" Stretch="Fill"  
                             Fill="{StaticResource CirclesColor}" Opacity="0.2"/>
                    <Canvas.RenderTransform>
                        <RotateTransform x:Name="SpinnerRotate"  
                             Angle="0" />
                    </Canvas.RenderTransform>
                </Canvas>
            </Grid>
        </Viewbox>
    </UserControl>

    使用:

    <local:LoadingWait x:Name="_loading"  Visibility="Collapsed" Grid.Row="1" HorizontalAlignment="Center" Margin="0,-120,0,0"/>

    控制隐藏或显示

    this._loading.Visibility = Visibility.Visible;

    this._loading.Visibility = Visibility.Collapsed;

  • 相关阅读:
    33选6算法:M个数N个为一组,无重复的排列组合
    文件墙 CFilewall
    公司代码阅读笔记 记于 2013-09-23
    简单的同步MSMQ
    Markdown 使用说明
    Freezable 对象(WPF)
    AngularJS-入门篇
    第二节Unity3D开发环境安装(windows系统)
    第一节Unity3D简介
    数据库出现可疑解决办法
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/12713717.html
Copyright © 2011-2022 走看看