当用户点击最大化按钮时,我试图最大化窗口。问题是我使用的方法会在窗口最大化时将窗口缩小一半:
以下是我使用的方法:
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;
}
导致这种情况的原因是什么,无论如何都要解决最大化问题?