@@ -58,6 +58,32 @@ protected override void OnInitialized()
5858 extendedView = ( FrameworkElement ) this . ExtendedItem . View ;
5959 }
6060
61+ public override Rect GetPosition ( PlacementOperation operation , DesignItem item )
62+ {
63+ UIElement child = item . View ;
64+
65+ if ( child == null )
66+ return Rect . Empty ;
67+
68+ double x , y ;
69+
70+ if ( IsPropertySet ( child , Canvas . LeftProperty ) || ! IsPropertySet ( child , Canvas . RightProperty ) ) {
71+ x = GetCanvasProperty ( child , Canvas . LeftProperty ) ;
72+ } else {
73+ x = extendedComponent . ActualWidth - GetCanvasProperty ( child , Canvas . RightProperty ) - child . RenderSize . Width ;
74+ }
75+
76+
77+ if ( IsPropertySet ( child , Canvas . TopProperty ) || ! IsPropertySet ( child , Canvas . BottomProperty ) ) {
78+ y = GetCanvasProperty ( child , Canvas . TopProperty ) ;
79+ } else {
80+ y = extendedComponent . ActualHeight - GetCanvasProperty ( child , Canvas . BottomProperty ) - child . RenderSize . Height ;
81+ }
82+
83+ var p = new Point ( x , y ) ;
84+ return new Rect ( p , child . RenderSize ) ;
85+ }
86+
6187 public override void SetPosition ( PlacementInformation info )
6288 {
6389 base . SetPosition ( info ) ;
@@ -66,28 +92,26 @@ public override void SetPosition(PlacementInformation info)
6692 UIElement child = info . Item . View ;
6793 Rect newPosition = info . Bounds ;
6894
69- if ( IsPropertySet ( child , Canvas . RightProperty ) )
70- {
95+ if ( IsPropertySet ( child , Canvas . LeftProperty ) || ! IsPropertySet ( child , Canvas . RightProperty ) ) {
96+ if ( newPosition . Left != GetCanvasProperty ( child , Canvas . LeftProperty ) ) {
97+ info . Item . Properties . GetAttachedProperty ( Canvas . LeftProperty ) . SetValue ( newPosition . Left ) ;
98+ }
99+ } else {
71100 var newR = extendedComponent . ActualWidth - newPosition . Right ;
72101 if ( newR != GetCanvasProperty ( child , Canvas . RightProperty ) )
73102 info . Item . Properties . GetAttachedProperty ( Canvas . RightProperty ) . SetValue ( newR ) ;
74103 }
75- else if ( newPosition . Left != GetCanvasProperty ( child , Canvas . LeftProperty ) )
76- {
77- info . Item . Properties . GetAttachedProperty ( Canvas . LeftProperty ) . SetValue ( newPosition . Left ) ;
78- }
79104
80105
81- if ( IsPropertySet ( child , Canvas . BottomProperty ) )
82- {
106+ if ( IsPropertySet ( child , Canvas . TopProperty ) || ! IsPropertySet ( child , Canvas . BottomProperty ) ) {
107+ if ( newPosition . Top != GetCanvasProperty ( child , Canvas . TopProperty ) ) {
108+ info . Item . Properties . GetAttachedProperty ( Canvas . TopProperty ) . SetValue ( newPosition . Top ) ;
109+ }
110+ } else {
83111 var newB = extendedComponent . ActualHeight - newPosition . Bottom ;
84112 if ( newB != GetCanvasProperty ( child , Canvas . BottomProperty ) )
85113 info . Item . Properties . GetAttachedProperty ( Canvas . BottomProperty ) . SetValue ( newB ) ;
86114 }
87- else if ( newPosition . Top != GetCanvasProperty ( child , Canvas . TopProperty ) )
88- {
89- info . Item . Properties . GetAttachedProperty ( Canvas . TopProperty ) . SetValue ( newPosition . Top ) ;
90- }
91115
92116 if ( info . Item == Services . Selection . PrimarySelection )
93117 {
0 commit comments