自定义控件三部曲之动画篇(一)——alpha、scale、translate、rotate、set的xml属性及用法

http://blog.csdn.net/harvic880925/article/details/39996643

全部地址:http://blog.csdn.net/column/details/harvic2animation.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用以下方式来实现自定义控件新建属性并开放给使用此自定义控件的页面设置属性: 1. 在您的自定义控件的类中,定义一个属性,例如: ``` public class MyCustomControl : Control { public string MyCustomProperty { get; set; } } ``` 2. 在您的自定义控件的类中,重写 OnPaint 方法,并使用 MyCustomProperty 属性的值来绘制控件: ``` protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // 绘制控件,使用 MyCustomProperty 属性的值 } ``` 3. 在您的自定义控件的类中,使用 DesignerSerializationVisibilityAttribute 特性来控制 MyCustomProperty 属性的序列化可见性: ``` [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string MyCustomProperty { get; set; } ``` 4. 在您的自定义控件的类中,使用 DefaultValueAttribute 特性来设置 MyCustomProperty 属性的默认值: ``` [DefaultValue("default value")] public string MyCustomProperty { get; set; } ``` 5. 在您的自定义控件的类中,使用 PropertyChangedEventHandler 事件来通知使用此自定义控件的页面属性值的更改: ``` public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } private string _myCustomProperty; public string MyCustomProperty { get { return _myCustomProperty; } set { if (_myCustomProperty != value) { _myCustomProperty = value; OnPropertyChanged(nameof(MyCustomProperty)); } } } ``` 6. 在使用此自定义控件的页面中,使用 MyCustomControl 的实例,并设置 MyCustomProperty 属性的值: ``` var myCustomControl = new MyCustomControl(); myCustomControl.MyCustomProperty = "new value"; ``` 这样,您就可以通过 MyCustomProperty 属性来设置您的自定义控件属性,从而实现自定义控件新建属性并开放给使用此自定义控件的页面设置属性的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值