@@ -358,30 +358,28 @@ private void TabViewItem_Loaded(object sender, RoutedEventArgs e)
358358 }
359359 }
360360
361- private void DragAreaRectangle_Loaded ( object ? sender , RoutedEventArgs e )
361+ private async void DragAreaRectangle_Loaded ( object ? sender , RoutedEventArgs e )
362362 {
363- if ( HorizontalTabView . ActualWidth > 0 && TabBarAddNewTabButton . Width > 0 )
364- {
365- var appWindow = MainWindow . Instance . AppWindow ;
366- var titleBarInset = ( FilePropertiesHelpers . FlowDirectionSettingIsRightToLeft
367- ? appWindow . TitleBar . LeftInset
368- : appWindow . TitleBar . RightInset ) / DragAreaRectangle . XamlRoot . RasterizationScale ;
363+ if ( HorizontalTabView . ActualWidth <= 0 && TabBarAddNewTabButton . Width <= 0 )
364+ await Task . Delay ( 100 ) ;
369365
370- if ( titleBarInset > 0 )
371- {
372- titleBarInset += 40 ; // Add 40px gap
373- RightPaddingColumn . Width = new ( titleBarInset ) ;
366+ var appWindow = MainWindow . Instance . AppWindow ;
367+ var titleBarInset = ( FilePropertiesHelpers . FlowDirectionSettingIsRightToLeft
368+ ? appWindow . TitleBar . LeftInset
369+ : appWindow . TitleBar . RightInset ) / DragAreaRectangle . XamlRoot . RasterizationScale ;
374370
375- HorizontalTabView . Measure ( new (
376- HorizontalTabView . ActualWidth - TabBarAddNewTabButton . Width - titleBarInset ,
377- HorizontalTabView . ActualHeight ) ) ;
371+ if ( titleBarInset > 0 )
372+ {
373+ titleBarInset += 40 ; // Add 40px gap
374+ RightPaddingColumn . Width = new ( titleBarInset ) ;
378375
379- return ;
380- }
376+ HorizontalTabView . Measure ( new (
377+ HorizontalTabView . ActualWidth - TabBarAddNewTabButton . Width - titleBarInset ,
378+ HorizontalTabView . ActualHeight ) ) ;
379+ return ;
381380 }
382381
383- if ( sender is not null )
384- DispatcherQueue . TryEnqueue ( ( ) => DragAreaRectangle_Loaded ( null , e ) ) ;
382+ RightPaddingColumn . Width = new ( 138 ) ; // fallback
385383 }
386384 }
387385}
0 commit comments