Resize on the first launch

This commit is contained in:
Tian Liao 2024-04-28 12:21:49 +08:00
commit b60662db68

View file

@ -96,14 +96,17 @@ namespace CalculatorApp
var minWindowWidth = Convert.ToSingle(Resources["AppMinWindowWidth"]); var minWindowWidth = Convert.ToSingle(Resources["AppMinWindowWidth"]);
var minWindowHeight = Convert.ToSingle(Resources["AppMinWindowHeight"]); var minWindowHeight = Convert.ToSingle(Resources["AppMinWindowHeight"]);
var minWindowSize = SizeHelper.FromDimensions(minWindowWidth, minWindowHeight); 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 // For very first launch, set the size of the calc as size of the default standard mode
if (!localSettings.Values.ContainsKey("VeryFirstLaunch")) if (!localSettings.Values.ContainsKey("VeryFirstLaunch"))
{ {
localSettings.Values["VeryFirstLaunch"] = false; localSettings.Values["VeryFirstLaunch"] = false;
appView.TryResizeView(minWindowSize); appView.TryResizeView(minWindowSize); // the requested size must not be less than the min size.
} }
else else
{ {
@ -136,9 +139,6 @@ namespace CalculatorApp
throw new SystemException("6d430286-eb5d-4f8d-95d2-3d1059552968"); 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 // Place the frame in the current Window
Window.Current.Content = rootFrame; Window.Current.Content = rootFrame;
ThemeHelper.InitializeAppTheme(); ThemeHelper.InitializeAppTheme();