Hi Sudarshan,
Your description of the problem is a little confusing (to me). What do you mean with "when I maximize this window"?
Also the xaml file of your child (I guess) is not much help.
So just a short (General) answer first.
To center a child to it's parent Windows you have to set the
Owner
property of the child to the parent window before showing the child. This should be easy and always works.
But If I understand you right, you want to "center" the window after it was shown, when it's maximized (but doesn't occupy the whole screen because of your MaxWidth and MaxHeight settings? If so, I don't know a common solution for it you have to program the behaviour for yourself - maybe this could help:
http://stackoverflow.com/questions/4806088/how-can-i-find-the-position-of-a-maximized-window[
^]
Btw. I don't like to change user expectations on common OS operations. (If I click the maximize button of any window I expect it to - ahh - maximize to my screen size). Your window would maximize up to your limits and center to it's parent (if you get it working). So I'd either make it a "Dialog" Window without maximize/minimize option or provide a "special" menu option for that. So maybe you could question the requirement... Or maybe I missunderstood what you want..
Update:
A easy solution coul be to just "override" maximize behaviour by resetting
WindowState
in
StateChanged
Event to normal:
if (WindowState == System.Windows.WindowState.Maximized)
{
WindowState = System.Windows.WindowState.Normal;
this.Left = 500;
this.Top = 500;
}
Kind regards Johannes