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

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.

Related

"Make into Control" option in Microsoft Blend 2015

I have tried to use this Tool and I don't understand its purpose. In previous versions, it created a UserControl out of the selected controls. Now it creates a ButtonStyle for what I have seen.
How can I use this tool?
The old Blend has two options, Make Into UserControl and Make Into Control.
The Make Into UserControl wraps whatever you selected into a UserControl while the Make Into Control has always been turning whatever you selected into a Custom Control.
A Custom Control generally has a default style, and that's why you see that predefined ButtonStyle1 on the popup. A Button is a Custom Control, and that's why you can customize its look and feel by changing its style.
I'd strongly recommend you to have a read on how to create a Custom Control.

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

Editing attached property in Blend and VS 2010

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.

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.

WPF design-time context menu

I am trying to create a custom wpf control, I'm wondering how I can add some design-time features. I've googled and can't seem to get to my goal.
So here's my simple question, how can I add an entry to the design-time context menu for my WPF usercontrol? The context menu by default has entries View Code,View XAML, etc.
You probably want to check out the WPF Designer Extensibility documentation. Specifically it sounds like you want to create a custom MenuAction.
This will help you get the context menu you require, although this applies to datagrid's still applicable;
WPF DataGrid Design-time Walkthrough

Resources