WPF 重要新概念 之 属性依赖的实现
发布时间:2020-05-28 06:05:34 所属栏目:程序设计 来源:互联网
导读:依赖属性的实现 public class ButtonTest : ButtonBase { //依赖属性 public static readonly DependencyProperty IsDefaultProperty; public bool IsDefault { get { re
|
依赖属性的实现 public class ButtonTest : ButtonBase
{
//依赖属性
public static readonly DependencyProperty IsDefaultProperty;
public bool IsDefault
{
get { return (bool)GetValue(ButtonTest.IsDefaultProperty); }
set { SetValue(ButtonTest.IsDefaultProperty,value); }
}
static ButtonTest()
{
//注册属性
ButtonTest.IsDefaultProperty = DependencyProperty.Register("IsDefault",typeof(bool),typeof(ButtonTest),new FrameworkPropertyMetadata(false,new PropertyChangedCallback(IsDefaultChanged)));
}
/// <summary>
/// 属性改变时操作
/// </summary>
/// <param name="o"></param>
/// <param name="e"></param>
private static void IsDefaultChanged(DependencyObject o,DependencyPropertyChangedEventArgs e)
{
}
} 以后补充 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
