首页 > 其他分享 >【WPF】记录一些控件的实现

【WPF】记录一些控件的实现

时间:2023-02-10 13:22:25浏览次数:41  
标签:控件 XXXX DependencyProperty 记录 Point typeof WPF public board

1.流动路径

可以通过Path来定义路线,虚线从起点流向终点
<UserControl.Resources>
    <Storyboard x:Key="OnLoaded1" x:Name="_Storyboard" >
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeDashOffset)" Storyboard.TargetName="path" RepeatBehavior="Forever">
            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="-20"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</UserControl.Resources>

 <Canvas>
    <Path x:Name="path" Stroke="xxx" 
      StrokeThickness="xxx" StrokeDashArray="3,2">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="{Binding PathStartPoint, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:XXXX}}}">
                    <PolyLineSegment x:Name="_Path" Points="{Binding PathPoints, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:XXXX}}}"></PolyLineSegment>
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>
public XXXX()
{
    InitializeComponent();

    var board = (Storyboard)this.FindResource("OnLoaded1");
    board.Begin(this, true);
}

/// <summary>
/// 除起点外的路径
/// </summary>
public PointCollection PathPoints
{
    get { return (PointCollection)GetValue(PathPointsProperty); }
    set { SetValue(PathPointsProperty, value); }
}
public static readonly DependencyProperty PathPointsProperty =
    DependencyProperty.Register("PathPoints", typeof(PointCollection), typeof(XXXX));

/// <summary>
/// 暂时或开始
/// </summary>
public bool IsPauseStoryboard
{
    get { return (bool)GetValue(IsPauseStoryboardProperty); }
    set { SetValue(IsPauseStoryboardProperty, value); }
}
public static readonly DependencyProperty IsPauseStoryboardProperty =
    DependencyProperty.Register("IsPauseStoryboard", typeof(bool), typeof(XXXX), new PropertyMetadata(false, (d, e) => (d as XXXX)?.PauseOrBegin()));

/// <summary>
/// 路径起点,动画是从起点流向终点
/// </summary>
public Point PathStartPoint
{
    get { return (Point)GetValue(PathStartPointProperty); }
    set { SetValue(PathStartPointProperty, value); }
}
public static readonly DependencyProperty PathStartPointProperty =
    DependencyProperty.Register("PathStartPoint", typeof(Point), typeof(XXXX), new PropertyMetadata(new Point(0, 0)));

/// <summary>
/// 暂时或开始
/// </summary>
private void PauseOrBegin()
{
    var board = (Storyboard)this.FindResource("OnLoaded1");
    if (IsPauseStoryboard)
    {
        board.Pause(this);
    }
    else
    {
        board.Resume(this);
    }
}

标签:控件,XXXX,DependencyProperty,记录,Point,typeof,WPF,public,board
From: https://www.cnblogs.com/flashing-magic/p/17108569.html

相关文章

  • CentOS7-Oracle11g 安装记录
    1.CentOS7Oracle11g需要安装的依赖包binutils-2.23.52.0.1-12.el7.x86_64compat-libcap1-1.10-3.el7.x86_64compat-libstdc++-33-3.2.3-71.el7.i686compat-libst......
  • 2023-02-10 记录一下rn 图标使用方法(转载)
    我原本以为react-native的button有官方写好的icon可以使用,但没曾想没有,而且还没有官方出的icon,故此得寻找第三方插件:react-native-vector-icons插件地址:https://oblador.g......
  • 界面组件Telerik UI for WPF R1 2023——让导航栏变得更智能!
    TelerikUIforWPF拥有超过100个控件来创建美观、高性能的桌面应用程序,同时还能快速构建企业级办公WPF应用程序。UIforWPF支持MVVM、触摸等,创建的应用程序可靠且结构良......
  • 自我介绍和学习记录
    这个作业属于哪个课程https://edu.cnblogs.com/campus/fzzcxy/2023learning这个作业要求在哪里https://edu.cnblogs.com/campus/fzzcxy/2023learning/homework/1......
  • 云存储数据转移过程记录
    前言我本来picGo是采用的腾讯云的cos图床,但是我的个人网站springboot中只配置了阿里云的oss存储,所以我现在拥有两个对象存储,两个空间都用不完,而且我每年还要交两份钱所以......
  • 自我介绍与学习记录
    这个作业属于哪个课程https://edu.cnblogs.com/campus/fzzcxy/2023learning这个作业要求在哪里https://edu.cnblogs.com/campus/fzzcxy/2023learning/homework/1......
  • 自我介绍和学习记录
    这个作业属于哪个课程https://www.bilibili.com/video/BV1EW411u7th/?p=1&vd_source=216cf9b3022cb27589439297d6b1da9a这个作业要求在哪里https://edu.cnblogs.......
  • 自我介绍与学习内容记录
    自我介绍与学习内容记录这个作业属于哪个课程22级转专业同学寒假作业这个作业要求在哪里第一次寒假作业这个作业的目标自我介绍与学习内容记录自我介......
  • 自我介绍和学习记录
    这个作业属于哪个课程https://edu.cnblogs.com/campus/fzzcxy/2023learning这个作业要求在哪里https://edu.cnblogs.com/campus/fzzcxy/2023learning/homework/1......
  • 记录一个排查oom思路
    一、背景客户反馈系统白屏,同时运维反馈内存占用多。项目包括数据库等,是部署在不同docker里的二、查linux日志是linux将mysql杀掉了egrep-i-r'killedprocess'/var/l......