I have a method that takes in the height and width of the window when the WindowState changes with Window.StateChanged, but when I use the MS Windows docking to dock the Window, the application detects the change, runs the Event Handler, then docks and gives me the wrong height/width of the window.
private void Window_Loaded(object sender, RoutedEventArgs e) {
Window.StateChanged += new EventHandler(Window_StateChanged);
}
void Window_StateChanged(object sender, EventArgs e) {
EnvironmentalVariables.Instance.WindowHeight = Application.Current.MainWindow.Height - EnvironmentalVariables.MENUBARHEIGHT;
EnvironmentalVariables.Instance.WindowWidth = Application.Current.MainWindow.Width - EnvironmentalVariables.TREEWIDTH - 55;
}
Manual State Changing
Using Windows UI Docking
How do I make it so that the event handler will run after the docking occurs?
To make it clear, I'm not using a referenced Windows Docking, I'm using the Operating System docking in Windows 7 where you drag to a side of the screen and it docks for you.
did you tried ActualHeight\ActualWidth ?
Edit: (moved the answer here) the 'SizeChanged' event is called after 'StateChanged' and the size should be fine then you can update the size there