4 Replies - 4619 Views - Last Post: 27 September 2012 - 10:44 AM Rate Topic: -----

#1 Andrei95  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 17-December 11

Custom UserControl Binding Properties

Posted 24 September 2012 - 11:44 AM

Hello everyone!

I have a question about Custom UserControl binding properties. To be more specific, I've created a simple class like this one.

 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); }
            }
        }
    }




After I've searched all over the Internet I couldn't find the right answer so please, I want to ask you why I don't see in my DesignView the category Z with a brush in it.

Is This A Good Question/Topic? 0
  • +

Replies To: Custom UserControl Binding Properties

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Custom UserControl Binding Properties

Posted 24 September 2012 - 12:09 PM

Do you want to see your dependency property in the Property Window in Visual Studio?
Was This Post Helpful? 0
  • +
  • -

#3 Andrei95  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 17-December 11

Re: Custom UserControl Binding Properties

Posted 25 September 2012 - 05:46 AM

Yes, exactly! :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,076
  • Joined: 02-July 08

Re: Custom UserControl Binding Properties

Posted 25 September 2012 - 09:45 PM

I think this is what your looking for.

Dependency Property
Was This Post Helpful? 2
  • +
  • -

#5 Andrei95  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 17-December 11

Re: Custom UserControl Binding Properties

Posted 27 September 2012 - 10:44 AM

Yes, that was perfect, thank you :bigsmile:

Now my property looks something like this and it works perfectly fine:


 public static readonly DependencyProperty BGColor = DependencyProperty.Register("Background", typeof(Brush), typeof(UserControl1));
        [Description("BTNColor"), Category("Colors")]
        public Brush Background
        {
            get { return (Brush)GetValue(BGColor); }
            set { SetValue(BGColor, value); }
        }



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1