I'm trying to maximize a window when the user clicks on the maximize button. The problem is that the method that I use cuts the window in half whenever it's maximized:
Here is the method that I used :
void OnStateChanged(object sender, EventArgs args)
{
if (WindowState == WindowState.Minimized)
{
if (Messenger.Option.showlearnetlogo)
{
Logo.Visibility = Visibility.Hidden;
this.Title = Properties.Resources.MainView_OnStateChanged_Learnet_Communicator;
}
for (int i = App.Current.Windows.Count - 1; i >= 0; i--)
{
if (App.Current.Windows[i].IsActive)
App.Current.Windows[i].WindowState = WindowState.Minimized;
}
}
else if (WindowState == WindowState.Maximized)
{
if (prevwinstate == WindowState.Minimized)
WindowState = WindowState.Normal;
m_storedWindowState = WindowState;
}
else
{
if (Messenger.Option.showlearnetlogo)
{
this.Title = "";
Logo.Visibility = Visibility.Visible;
}
m_storedWindowState = WindowState;
}
prevwinstate = WindowState;
}
What is causing this and is there anyway to fix the maximizing problem?