locked
How do you add attributes to AttachedProperty<T> RRS feed

  • Question

  • I have a designer where I add attached properties to the ModelItem. These then seem to get converted to ModelProperty which is accessed via ModelItem.Properties. How can I add attributes to these properties to make the property grid nicer. I want to add attributes like Description and Category (perhaps IsBrowsable if that is possible as well); 
    Tuesday, September 21, 2010 10:54 AM

Answers

  • Hi, Rory

    This sample could be helpful:
    http://msdn.microsoft.com/en-us/library/ee834515.aspx

    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    • Marked as answer by Andrew_Zhu Tuesday, September 28, 2010 7:21 AM
    Thursday, September 23, 2010 7:47 AM
  • Because it already has its own unextensible property descriptor, I don't think it's likely possible to add attributes on the attached property itself. Except for BrowsableAttribute, which you set by attachedProperty.IsBrowsable.

    But it does still pick up attributes found on the type descriptor for type T.

    Tim

    • Marked as answer by Andrew_Zhu Tuesday, September 28, 2010 7:21 AM
    Thursday, September 23, 2010 11:50 PM

All replies

  • Hi, Rory

    This sample could be helpful:
    http://msdn.microsoft.com/en-us/library/ee834515.aspx

    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    • Marked as answer by Andrew_Zhu Tuesday, September 28, 2010 7:21 AM
    Thursday, September 23, 2010 7:47 AM
  • Thanks Andrew. I missed that the AddCustomAttributes method had an overload for members.

    This works really well for properties defined against the activity itself. Unfortunately it doesn't work for attached properties that would get hooked up in the designer OnModelItemChanged event which would occur well after the IRegisterMetadata.Register invocation.

    Any other thoughts? Is there a type descriptor somewhere that I can use to help define attached property details?

    Thursday, September 23, 2010 12:42 PM
  • Because it already has its own unextensible property descriptor, I don't think it's likely possible to add attributes on the attached property itself. Except for BrowsableAttribute, which you set by attachedProperty.IsBrowsable.

    But it does still pick up attributes found on the type descriptor for type T.

    Tim

    • Marked as answer by Andrew_Zhu Tuesday, September 28, 2010 7:21 AM
    Thursday, September 23, 2010 11:50 PM