2

I have an attached property and I am registering it with the designer using a design-time assembly. I am using the AttachedPropertyBrowsableForTypeAttribute so that the property will be shown when a TextBox is selected.

The property shows up fine in Expression Blend 4, but does not show in Visual Studio 2010 SP1.

Expression Blend

Visual Studio

Does anyone know why it would not show up in Visual Studio? You can download a test project demonstrating the problem from here: Test Project

Thanks!

H.B.
  • 166,899
  • 29
  • 327
  • 400
Frank Wallis
  • 581
  • 7
  • 12

1 Answers1

1

The short answer is indeed because the Cider designer is a complete piece of crap. Here's the longer answer:

From a Microsoft blog:

One thing to keep in mind is that one of the requirements of showing attached properties in the designer is that the owning type needs to have been loaded by the designer. This happens whenever the designer accesses the type because it is in the XAML source or is a dependency of an element loaded from the XAML source.

So the problem is the Cider designer only cares about types which have already been loaded. You can see an example of this by changing your containing Grid to a StackPanel: the Grid.Row and Grid.Column attached properties will then disappear from the list of TextBox properties within Visual Studio. The Blend design surface is somehow more forgiving and recognizes your type. In addition, Blend dutifully displays the Grid.IsSharedSizeScope (under Layout properties) even when using a StackPanel.

Looking at how Microsoft uses and supports attached properties, they seem to favor using them on layout containers. For example there's the AttachedPropertyBrowsableForChildrenAttribute. It's so you can do things like show Canvas.Left for children of a Canvas element. I get the impression they did not thoroughly consider how most people actually are using attached properties today (bolting functionality onto the side of an object versus having functionality flow downhill from a parent).

Mike Post
  • 6,355
  • 3
  • 38
  • 48