为什么我的自定义依赖项属性不会出现在Expression Blend道具中? [英] Why does my custom dependency property not show up in Expression Blend props?

查看:66
本文介绍了为什么我的自定义依赖项属性不会出现在Expression Blend道具中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的自定义依赖项属性不会出现在Expression Blend 4中? 


例如..我在dafault Silverlight 4 +网站中创建一个简单的依赖属性Expression Blend 4中的项目:

 public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register(
MyProperty",// Property name
typeof(double), //属性类型
typeof(MainPage),//依赖项属性提供程序的类型
new PropertyMetadata(new PropertyChangedCallback(MyPropertyChanged))); //对属性值调用的回调已更改

[System.ComponentModel.Description("这是工具提示中显示的描述文本。)]
[System.ComponentModel.Category(" UserControl1 Category")]
public double MyProperty
{
set
{
this.SetValue(MyPropertyProperty,value);
}

get
{
return(double)this.GetValue(MyPropertyProperty);
}
}

 我可以使用dp没问题..但它不会出现在属性下的Expreesion Blend中。 勉强的,如果我把我的usercontrol转到另一个项目..它就行了!


为什么会这样?

解决方案

< blockquote>这样的属性意味着要在UC的实例上设置,而不是在实际的UC本身内部。这就是为什么它在另一个项目中创建UC MainPage实例时出现的原因。


Why does my custom dependency property not show up in Expression Blend 4? 

For Example.. I create a simply dependency property in a dafault Silverlight 4 + Website project in Expression Blend 4:

    public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register(
      MyProperty",        //Property name
      typeof(double),       //Property type
      typeof(MainPage),    //Type of the dependency property provider
      new PropertyMetadata(new PropertyChangedCallback(MyPropertyChanged)));//Callback invoked on property value has changes

    [System.ComponentModel.Description("This is the description text that shows in a tooltip.")]
    [System.ComponentModel.Category("UserControl1 Category")]
    public double MyProperty
    {
      set
      {
        this.SetValue(MyPropertyProperty, value);
      }

      get
      {
        return (double)this.GetValue(MyPropertyProperty);
      }
    }

 I can use the dp no problem.. but it does NOT show up in Expreesion Blend under the properties.  Strangly enough, if I had my usercontrol to another project.. it DOES!

Why is this?

解决方案

Properties like this are meant to be set on an instance of your UC, not inside the actual UC itself. This is why it shows up when you created an instance of the UC MainPage in another project.


这篇关于为什么我的自定义依赖项属性不会出现在Expression Blend道具中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆