File tree Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 22// Licensed under the MIT License. See the LICENSE.
33
44using Microsoft . UI . Xaml . Controls ;
5+ using System . Runtime . InteropServices ;
56using Windows . ApplicationModel . DataTransfer ;
67
78namespace Files . App . Data . Models
@@ -35,11 +36,18 @@ public int TabStripSelectedIndex
3536 {
3637 SetProperty ( ref _TabStripSelectedIndex , value ) ;
3738
38- if ( value >= 0 && value < MainPageViewModel . AppInstances . Count )
39+ try
3940 {
40- var rootFrame = ( Frame ) MainWindow . Instance . Content ;
41- var mainView = ( MainPage ) rootFrame . Content ;
42- mainView . ViewModel . SelectedTabItem = MainPageViewModel . AppInstances [ value ] ;
41+ if ( value >= 0 && value < MainPageViewModel . AppInstances . Count )
42+ {
43+ var rootFrame = ( Frame ) MainWindow . Instance . Content ;
44+ var mainView = ( MainPage ) rootFrame . Content ;
45+ mainView . ViewModel . SelectedTabItem = MainPageViewModel . AppInstances [ value ] ;
46+ }
47+ }
48+ catch ( COMException )
49+ {
50+
4351 }
4452 }
4553 }
Original file line number Diff line number Diff line change 88using Microsoft . UI . Xaml . Controls ;
99using Microsoft . UI . Xaml . Controls . Primitives ;
1010using Microsoft . UI . Xaml . Input ;
11+ using System . Runtime . InteropServices ;
1112using Windows . System ;
1213using Windows . UI . Core ;
1314using Windows . Win32 ;
@@ -276,12 +277,19 @@ protected virtual async Task CommitRenameAsync(TextBox textBox)
276277
277278 protected virtual async void RenameTextBox_LostFocus ( object sender , RoutedEventArgs e )
278279 {
279- // This check allows the user to use the text box context menu without ending the rename
280- if ( ! ( FocusManager . GetFocusedElement ( MainWindow . Instance . Content . XamlRoot ) is AppBarButton or Popup ) )
280+ try
281281 {
282- TextBox textBox = ( TextBox ) e . OriginalSource ;
283- await CommitRenameAsync ( textBox ) ;
282+ // This check allows the user to use the text box context menu without ending the rename
283+ if ( ! ( FocusManager . GetFocusedElement ( MainWindow . Instance . Content . XamlRoot ) is AppBarButton or Popup ) )
284+ {
285+ TextBox textBox = ( TextBox ) e . OriginalSource ;
286+ await CommitRenameAsync ( textBox ) ;
287+ }
284288 }
289+ catch ( COMException )
290+ {
291+
292+ }
285293 }
286294
287295 // Methods
Original file line number Diff line number Diff line change 99using Microsoft . UI . Xaml . Media . Animation ;
1010using Microsoft . UI . Xaml . Navigation ;
1111using System . Runtime . CompilerServices ;
12+ using System . Runtime . InteropServices ;
1213using Windows . Foundation . Metadata ;
1314using Windows . System ;
1415using Windows . UI . Core ;
@@ -756,10 +757,17 @@ protected void SelectSidebarItemFromPath(Type incomingSourcePageType = null)
756757
757758 protected void SetLoadingIndicatorForTabs ( bool isLoading )
758759 {
759- var multitaskingControls = ( ( MainWindow . Instance . Content as Frame ) . Content as MainPage ) . ViewModel . MultitaskingControls ;
760+ try
761+ {
762+ var multitaskingControls = ( ( MainWindow . Instance . Content as Frame ) . Content as MainPage ) . ViewModel . MultitaskingControls ;
760763
761- foreach ( var x in multitaskingControls )
762- x . SetLoadingIndicatorStatus ( x . Items . FirstOrDefault ( x => x . TabItemContent == PaneHolder ) , isLoading ) ;
764+ foreach ( var x in multitaskingControls )
765+ x . SetLoadingIndicatorStatus ( x . Items . FirstOrDefault ( x => x . TabItemContent == PaneHolder ) , isLoading ) ;
766+ }
767+ catch ( COMException )
768+ {
769+
770+ }
763771 }
764772
765773 // WINUI3
You can’t perform that action at this time.
0 commit comments