@@ -36,16 +36,29 @@ public MainWindow()
3636 {
3737 this . InitializeComponent ( ) ;
3838 SetWindowProperties ( ) ;
39- RootGrid . ActualThemeChanged += ( _ , _ ) => TitleBarHelper . ApplySystemThemeToCaptionButtons ( this , RootGrid . ActualTheme ) ;
39+ RootGrid . ActualThemeChanged += ( _ , _ ) => TitleBarHelper . ApplySystemThemeToCaptionButtons ( this , RootGrid . ActualTheme ) ;
4040 dispatcherQueue = Microsoft . UI . Dispatching . DispatcherQueue . GetForCurrentThread ( ) ;
4141 }
4242
4343 private void RootGrid_Loaded ( object sender , RoutedEventArgs e )
4444 {
45+ // We need to set the minimum size here because the XamlRoot is not available in the constructor.
46+ WindowHelper . SetWindowMinSize ( this , 640 , 500 ) ;
47+
48+ if ( sender is FrameworkElement rootGrid && rootGrid . XamlRoot is not null )
49+ {
50+ rootGrid . XamlRoot . Changed += RootGridXamlRoot_Changed ;
51+ }
52+
4553 NavigationOrientationHelper . UpdateNavigationViewForElement ( NavigationOrientationHelper . IsLeftMode ( ) ) ;
4654 TitleBarHelper . ApplySystemThemeToCaptionButtons ( this , RootGrid . ActualTheme ) ;
4755 }
4856
57+ private void RootGridXamlRoot_Changed ( XamlRoot sender , XamlRootChangedEventArgs args )
58+ {
59+ WindowHelper . SetWindowMinSize ( this , 640 , 500 ) ;
60+ }
61+
4962 private void SetWindowProperties ( )
5063 {
5164#if DEBUG
@@ -58,9 +71,6 @@ private void SetWindowProperties()
5871 this . SetTitleBar ( titleBar ) ;
5972 this . AppWindow . SetIcon ( "Assets/Tiles/GalleryIcon.ico" ) ;
6073 this . AppWindow . TitleBar . PreferredHeightOption = TitleBarHeightOption . Tall ;
61-
62- Win32WindowHelper win32WindowHelper = new Win32WindowHelper ( this ) ;
63- win32WindowHelper . SetWindowMinMaxSize ( new Win32WindowHelper . POINT ( ) { x = 640 , y = 500 } ) ;
6474 }
6575
6676 private void OnPaneDisplayModeChanged ( NavigationView sender , NavigationViewDisplayModeChangedEventArgs args )
0 commit comments