From b60662db68fe871f5acd96a1f5eca144b02d3e56 Mon Sep 17 00:00:00 2001 From: Tian Liao Date: Sun, 28 Apr 2024 12:21:49 +0800 Subject: [PATCH] Resize on the first launch --- src/Calculator/App.xaml.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Calculator/App.xaml.cs b/src/Calculator/App.xaml.cs index 449ce6db..8ca14222 100644 --- a/src/Calculator/App.xaml.cs +++ b/src/Calculator/App.xaml.cs @@ -96,14 +96,17 @@ namespace CalculatorApp var minWindowWidth = Convert.ToSingle(Resources["AppMinWindowWidth"]); var minWindowHeight = Convert.ToSingle(Resources["AppMinWindowHeight"]); var minWindowSize = SizeHelper.FromDimensions(minWindowWidth, minWindowHeight); + var appView = ApplicationView.GetForCurrentView(); + var localSettings = ApplicationData.Current.LocalSettings; + + // SetPreferredMinSize should always be called before Window.Activate + appView.SetPreferredMinSize(minWindowSize); - ApplicationView appView = ApplicationView.GetForCurrentView(); - ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; // For very first launch, set the size of the calc as size of the default standard mode if (!localSettings.Values.ContainsKey("VeryFirstLaunch")) { localSettings.Values["VeryFirstLaunch"] = false; - appView.TryResizeView(minWindowSize); + appView.TryResizeView(minWindowSize); // the requested size must not be less than the min size. } else { @@ -136,9 +139,6 @@ namespace CalculatorApp throw new SystemException("6d430286-eb5d-4f8d-95d2-3d1059552968"); } - // SetPreferredMinSize should always be called before Window.Activate - appView.SetPreferredMinSize(minWindowSize); - // Place the frame in the current Window Window.Current.Content = rootFrame; ThemeHelper.InitializeAppTheme();