c# - horizontally center vertically maximized WPF window -


i have wpf window has maxwidth set, when hit maximize button, maximizes vertically not horizontally. expected behavior. however, window docks left side of screen (windows 7, if matters) , want centered horizontally when maximized. tried adding following statechanged event handler, doesn't seem anything:

private void wdw_mainwindow_statechanged(object sender, eventargs e) {     switch (windowstate)     {         case windowstate.maximized:             var windowwidth = (double)getvalue(widthproperty);             left = (systemparameters.primaryscreenwidth / 2) - (windowwidth / 2);             break;     } } 

i set breakpoint on switch statement , code gets hit when hit maximize button in app. however, after left gets set, window remains firmly stuck left side of screen. what's going on?

aero snap on windows 7 interfering attempt center window. try turning off aero snap , see if still have problem.

http://www.sevenforums.com/tutorials/3069-aero-snap-turn-off.html


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -