窗口状态最大化方法将窗口最大化切成一半

时间:2017-12-06 04:46:25

标签: c# xaml windowstate

当用户点击最大化按钮时,我试图最大化窗口。问题是我使用的方法会在窗口最大化时将窗口缩小一半:

enter image description here

以下是我使用的方法:

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;
}

导致这种情况的原因是什么,无论如何都要解决最大化问题?

0 个答案:

没有答案