First I will give you my code and after that I will ask my question.
namespace LinearGradientBrushBinding
{
public partial class LinearGradBrush : UserControl
{
public LinearGradBrush()
{
InitializeComponent();
}
class LinearGradBrushProp : DependencyObject
{
public static DependencyProperty _background;
static void BackgroundBrush()
{
_background = DependencyProperty.Register(
"_background", typeof(Brush), typeof(LinearGradBrushProp));
}
[Description("CuloareBG"), Category("Z")]
public Brush Background
{
get { return (Brush)GetValue(_background); }
set { SetValue(_background, value); }
}
}
}
}
As you can see I have an UserControl which has in it a class. My question is why I don’t see in the Property window (right side of UserControl.Xaml) of my control the category Z with a brush in it.
Quite simply because your
LinearGradBrushdoesn’t contain a property annotated with the categoryZ.Your
LinearGradBrushcontains a (private) inner class that does have such a property, but there’s no way the property editor can know which instance of this inner class to assign a property value to. (The property editor might not even be able to see this inner class, given that it is private.)I recommend that you move this property out of your inner class and get rid of the class. I cannot honestly see a reason why you would need to use an inner class here.
Also, I’d like to point out that your dependency property isn’t declared correctly. It doesn’t use the correct naming conventions, and I cannot see any call to the
BackgroundBrush()method which initialises the dependency property. I would expect the property to be declared as follows (note the name of the field, the fact that it isreadonlyand that the first parameter of theRegistermethod is the name of the property):I made this change to your code, switched to another XAML page (i.e. not
LinearGradBrush.xaml), and added your control to this XAML page as an element<local:LinearGradBrush />. While the text cursor was over this element, theBackgroundproperty appeared in theZcategory of the properties window.