Position the window on opening

Feb 5, 2010 at 7:45 PM

Hello all,

                  I would like to know if it is possible to position the window in the container right on opening.

I know that it is possible with the horizontal and verticalalignment property but the window can't be moveable when we use those property.

Thanx a lot ...

Feb 6, 2010 at 5:05 PM


You can calculate the margin throught whe container width.




Feb 8, 2010 at 1:59 PM

Thank you but when i use margin i got problem on resize.

Any other solution ? :)

Thanx a lot !

Feb 10, 2010 at 10:51 AM


You must set up margins but remains alignments centered to work with resize. So, you must consider in your margin calculus that the behaviour is centered and you probably need to work with all margins (left and right for horizontal, for example) or set greater values to put the window in the place that you need. You can learn about centered alignements with margins in Exression Blend, in the designer view you can see how the margin values changes in centered alignments.


Aug 6, 2010 at 1:34 PM

If you do it this way can you get the windows new location when you drop the window at a new location? Lets say if you e.g. want to store the new window location in Isolated Storage and retreive it the next time you run the program...

Nov 21, 2010 at 8:29 PM


Sorry for late reply.

Absolutely, you can easly save the margins and set it up on window construction.



Jan 19, 2012 at 12:41 AM

Sample to setup margins shift Left=50 and Top=50 from the center:

window.Margin = new Thickness(50, 50, -50, -50)