首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

WPF DependencyProperty 自定义依赖项属性的有关问题

2012-01-13 
WPF DependencyProperty 自定义依赖项属性的问题我参考http://msdn.microsoft.com/zh-cn/partners/system.

WPF DependencyProperty 自定义依赖项属性的问题
我参考http://msdn.microsoft.com/zh-cn/partners/system.windows.dependencyproperty(VS.95).aspx
定义名为LabelText的用户控件 自定义属性名为LabelName

C# code
    public partial class LabelText : UserControl    {        public static readonly DependencyProperty LabelTextProperty =            DependencyProperty.Register(            "LabelName", typeof(String),            typeof(LabelText), null            );        public String LabelName        {            get { return (String)GetValue(LabelTextProperty); }            set { SetValue(LabelTextProperty, value); }        }        public LabelText()        {            InitializeComponent();//this.LabelName始终为NULL        }    }

我是使用如下方式引用该控件并初始值的
<....
 xmlns:common="clr-namespace:CommonControl"
>
<common:LabelText LabelName="道具名称"></common:LabelText>

但在我的LabelText类的构造中无法得到LabelName为“道具名称” 它始终为NULL.
为何??????????????

[解决办法]
http://www.langsin.com/index.html?ID=30可以看看视频教程

热点排行