无法放大 Window 大小

Unable to Enlarge Window Size

我的应用有一个迷你模式,使用这两行代码进入:

    (Window.Current.Content as Frame).Navigate(typeof(MiniModePage));
    await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, MiniModePage.ViewModePreferences);

这是MiniModePage.ViewModePreferences:

    public static Size PageSize { get => new Size(300, Settings.settings.MiniModeWithDropdown ? 900 : 300); }

    public static ViewModePreferences ViewModePreferences
    {
        get
        {
            var pref = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
            pref.CustomSize = PageSize;
            return pref;
        }
    }

MiniModePage 中,我允许通过单击按钮调整我的应用程序 window 的大小:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        SpinArrowAnimation.Begin();
        Settings.settings.MiniModeWithDropdown = !Settings.settings.MiniModeWithDropdown;
        var size = PageSize;
        ApplicationView.GetForCurrentView().SetPreferredMinSize(size);
        ApplicationView.GetForCurrentView().TryResizeView(size);
    }

问题是,我可以缩小 window 尺寸,但是当我尝试将 window 从 300 * 300 尺寸放大到 300 * 900 时,window大小不变。它始终保持 300 * 300。

如何让 window 不断调整大小?

另外一个问题是,300*900window显然没有1*3的尺寸比例,如下图。我该如何解决?

更多源代码:

  1. MiniModePage

  2. 输入MiniModePage的代码是MiniModeButton_Click中的here

The problem is that, I am able to shrink the window size down but when I try to enlarge the window from the size of 300 * 300 to 300 * 900, the window size does not change. It always stays 300 * 300.

请检查 SetPreferredMinSize 文档,

The smallest allowed minimum size is 192 x 48 effective pixels. The largest allowed minimum size is 500 x 500 effective pixels. If you set a value outside of these bounds, it is coerced to be within the allowed bounds. (To learn about effective pixels, see Responsive design 101 for .)

所以,请将您的最大身高从 900 修改为 500。

private void Button_Click(object sender, RoutedEventArgs e)
{
    SpinArrowAnimation.Begin();
    Settings.settings.MiniModeWithDropdown = !Settings.settings.MiniModeWithDropdown;
    var size = new Size(300,500);
    ApplicationView.GetForCurrentView().SetPreferredMinSize(size);
    ApplicationView.GetForCurrentView().TryResizeView(size);
}