Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Property Grid - Adding Custom Properties.

$
0
0
In my application I have a WPF canvas and I drag and drop items on that canvas. I want to see the Left and Top position of a selected item in the canvas. I tried to add two new properties(Top, Left) to the item class.

I am successful in changing the value of Top and Left in Property Grid when the items are moved, but unable to move the items when value is changed in the Property Grid.

While debugging I noticed that the Set part of my properties are not getting called when I change the property values in Property Grid. Thus it is not getting reflected on the items.

I also tried with OnSelectedPropertyItemChanged event but unable to get the new value of the property.

I have declared properties like this.
 #region Left

        public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof (Double),
                                                                                             typeof (CanvasItem));

        public Double Left
        {
            get { return (Double)GetValue(LeftProperty); }
            set
            {
                SetValue(LeftProperty, value);
                if (LeftProperty != null) Canvas.SetLeft(this, (Double)value);
            }
        }

        #endregion

        #region Top

        public static readonly DependencyProperty TopProperty = DependencyProperty.Register("Top", typeof(Double),
                                                                                             typeof(CanvasItem));

        public Double Top
        {
            get { return (Double)GetValue(TopProperty); }
            set { SetValue(TopProperty, value); }
        }

        #endregion
I am trying to get properties of type 'CanvasItem'.

Is there any way to resolve this.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>