wpf 用户控件上启用拖放功能

微软官方例程

https://learn.microsoft.com/zh-cn/dotnet/desktop/wpf/advanced/walkthrough-enabling-drag-and-drop-on-a-user-control

public Circle(Circle c)
{
    InitializeComponent();
    this.circleUI.Height = c.circleUI.Height;
    this.circleUI.Width = c.circleUI.Height;
    this.circleUI.Fill = c.circleUI.Fill;
}

同以下:

        public Circle()
        {
            InitializeComponent();
        }

        public Circle(Circle c) : this()
        {
            this.circleUI.Height = c.circleUI.Height;
            this.circleUI.Width = c.circleUI.Width;
            this.circleUI.Fill = c.circleUI.Fill;
        }

 

在 C# 的构造函数中,: this() 和 : base() 的核心区别在于它们调用的目标不同:: this() 调用当前类的其他构造函数,而 : base() 调用其基类(父类)的构造函数。

posted @ 2026-03-31 10:44  echo-efun  阅读(4)  评论(0)    收藏  举报