@@ -73,26 +73,21 @@ public void SetupApp(AppBuilder builder)
7373 v . dwOSVersionInfoSize = ( uint ) Marshal . SizeOf < RTL_OSVERSIONINFOEX > ( ) ;
7474 if ( RtlGetVersion ( ref v ) == 0 && ( v . dwMajorVersion < 10 || v . dwBuildNumber < 22000 ) )
7575 {
76- Window . WindowStateProperty . Changed . AddClassHandler < Window > ( ( w , e ) =>
77- {
78- if ( w . WindowState != WindowState . Maximized )
79- {
80- var margins = new MARGINS { cxLeftWidth = 1 , cxRightWidth = 1 , cyTopHeight = 1 , cyBottomHeight = 1 } ;
81- DwmExtendFrameIntoClientArea ( w . TryGetPlatformHandle ( ) . Handle , ref margins ) ;
82- }
83- } ) ;
84-
85- Window . LoadedEvent . AddClassHandler < Window > ( ( w , e ) =>
86- {
87- if ( w . WindowState != WindowState . Maximized )
88- {
89- var margins = new MARGINS { cxLeftWidth = 1 , cxRightWidth = 1 , cyTopHeight = 1 , cyBottomHeight = 1 } ;
90- DwmExtendFrameIntoClientArea ( w . TryGetPlatformHandle ( ) . Handle , ref margins ) ;
91- }
92- } ) ;
76+ Window . WindowStateProperty . Changed . AddClassHandler < Window > ( ( w , e ) => ExtendWindowFrame ( w ) ) ;
77+ Window . LoadedEvent . AddClassHandler < Window > ( ( w , e ) => ExtendWindowFrame ( w ) ) ;
9378 }
9479 }
9580
81+ private void ExtendWindowFrame ( Window w )
82+ {
83+ var platformHandle = w . TryGetPlatformHandle ( ) ;
84+ if ( platformHandle == null )
85+ return ;
86+
87+ var margins = new MARGINS { cxLeftWidth = 1 , cxRightWidth = 1 , cyTopHeight = 1 , cyBottomHeight = 1 } ;
88+ DwmExtendFrameIntoClientArea ( platformHandle . Handle , ref margins ) ;
89+ }
90+
9691 public string FindGitExecutable ( )
9792 {
9893 var reg = Microsoft . Win32 . RegistryKey . OpenBaseKey (
0 commit comments