This project has moved. For the latest updates, please go here.

Center of ChildWindow With Margins set

Mar 2, 2014 at 7:18 PM

The ChildWindow does not seem to respect margins when calculating the centering. I would like to place the control, so that the modal background does not obscure my ribbon, but still be in the centre of the screen if I place it underneath the ribbon it gets displayed slightly to the bottom (obviously because it excludes the ribbon height in its calculations). If I place it above the ribbon (Fluent), the modal background obscures it in an ugly way. Then if you give it a margin to exclude the ribbon, it places the dialog way down at the bottom.

Thanx, I really would prefer not to hack your code :)

Mar 3, 2014 at 2:11 PM
Edited Mar 3, 2014 at 2:19 PM

What I would do is place the windowContainer underneath the ribbon. Something like :
   <Ribbon />
             <ChildWindow />

The ChildWindow would have the 2 following properties :
Margin="0,0,0,25" //25 is half the size of the ribbon's height

Then modifying the toolkit Code :

In file :Xceed.Wpf.Toolkit/Core/Primitives/WindowContainer.cs
in method : CenterChild
Replace the "if" content with this :
windowControl.Left = ( this.ActualWidth - windowControl.ActualWidth ) / 2.0;
windowControl.Left += (windowControl.Margin.Left - windowControl.Margin.Right);
windowControl.Top = ( this.ActualHeight - windowControl.ActualHeight ) / 2.0;
windowControl.Top += ( windowControl.Margin.Top - windowControl.Margin.Bottom );
Normally, the ChildWidow is centered in the WindowContainer. With this, the ChildWindow will be offsetted from this center.
Mar 3, 2014 at 6:58 PM
Thanx, I was hoping not to modify your code... but if there is no other way :)

May 21, 2014 at 7:16 PM
This issue is fixed in v2.3.
"In ChildWindow, a centered childWindow can be offset with its margin property."