Editing attached property in Blend and VS 2010 - silverlight

I defined an attached property in silverlight that I want to use it on Silverlight's TextBox
Is there a way to show this property on the property page in Blend, and VS 2010
Like we do with the attached property Grid.Column, Grid.Row, where we can set them on VS 2010?
and if yes, Can I create its own PropertyValueEditor using Silverlight extensibility?
Thanks for help

The only way that you can do this in Blend is by creating a Behavior that sets the property and creating a design-time assembly for the behavior.
Here are articles on creating a Silverlight Design-time assemblies.
Expression Blend has a file template for Behaviors - start with that and create properties that mirror each of the attached properties - call the setters/getters in those properties.

Related

How to disable the New button in property browser of Blend?

I'm developing a custom control in WPF. This control has some properties whose type is custom class.When editting these properties in the Property Browser of Blend, there is a New button beside the editting property, While VS is not the case. My question is how to disable this New button in Blend.
Thanks in advance.
You can mark your properties with attributes that tell Blend (and Visual Studio) what to do with them. One of them is the BrowsableAttribute.
To hide the property, just add the following:
[Browsable(false)]
There are a whole lot more attributes in the System.ComponentModel namespace that you can use to customize the way properties in Blend and Visual Studio the DescriptionAttribute and CategoryAttribute.

Why does my Attached Property show in Blend designer but not in VS2010?

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.
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!
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).

Visual Studio Designer Attached Properties

I am using attached properties to allow some design-time behaviour in the Visual Studio WPF designer i.e. design-time view-model data.
The issue I'm having is that when attached property events fire at design-time for my UserControl, the type of the DependencyObject is UserControl and not the concrete type I am expecting. At runtime the type of the DependencyObject is the concrete type as expected, e.g. BlingUserControl.
I want access to the concrete type as I need its namespace for a convention-based locater pattern.
Is there any way of getting at the concrete type at design-time?
Afraid not. Visual Studio (and Blend, for that matter) both construct an instance of UserControl rather than an instance of your control itself.

WPF Designer Extensibility for TextBox

I want to modify the property table in VS 2010 that is associated with silverlight textbox.
I like to add a new property to the property table of a silverlight textbox without creating a custom control.
If I want to add a property called "Default value", and I want to run custom code when the user assign it from design-time property table
Can I do that?
I am reading about WPF designer extensibility, but all what I can find are for custom controls with custom properties.
Can we do it for an existing control?
No it is certainly not possible. You have to create a custom control thats the only way.

No Visual property of RowDetalsTemplate in the data grid

I want to add row details to each row, however I don't find RowDetailsTemplate property in the datagrid to add row details through UI. Do I need to manually change xaml?
I am using recent version of WPF Toolkit which requires 3.5 Sp1. Also using Visual Studio 2008 Sp1.
The property grid of the XAML Designer in VS 2008 generally doesn't show any properties of type FrameworkTemplate (and derived types, like DataTemplate). Only the VS2010 designer added these properties, and lets you select an existing template resource.
So, short reply: Yes, in VS2008, you have to manually edit the XAML in order to define a RowDetailsTemplate.

Resources