diff --git a/WinUIGallery/ControlPages/FilePickerPage.xaml.cs b/WinUIGallery/ControlPages/FilePickerPage.xaml.cs index a5240de41..89a327700 100644 --- a/WinUIGallery/ControlPages/FilePickerPage.xaml.cs +++ b/WinUIGallery/ControlPages/FilePickerPage.xaml.cs @@ -27,6 +27,10 @@ public FilePickerPage() private async void PickAFileButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickAFileOutputTextBlock.Text = ""; @@ -67,10 +71,16 @@ private async void PickAFileButton_Click(object sender, RoutedEventArgs e) PickAFileOutputTextBlock.Text = "Operation cancelled."; } + //re-enable the button + senderButton.IsEnabled = true; UIHelper.AnnounceActionForAccessibility(sender as Button, PickAFileOutputTextBlock.Text, "FilePickedNotificationId"); } private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickAPhotoOutputTextBlock.Text = ""; @@ -114,11 +124,17 @@ private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e) PickAPhotoOutputTextBlock.Text = "Operation cancelled."; } + //re-enable the button + senderButton.IsEnabled = true; UIHelper.AnnounceActionForAccessibility(sender as Button, PickAPhotoOutputTextBlock.Text, "PhotoPickedNotificationId"); } private async void PickFilesButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickFilesOutputTextBlock.Text = ""; @@ -164,11 +180,17 @@ private async void PickFilesButton_Click(object sender, RoutedEventArgs e) PickFilesOutputTextBlock.Text = "Operation cancelled."; } + //re-enable the button + senderButton.IsEnabled = true; UIHelper.AnnounceActionForAccessibility(sender as Button, PickFilesOutputTextBlock.Text, "FilesPickedNotificationId"); } private async void PickFolderButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickFolderOutputTextBlock.Text = ""; @@ -211,11 +233,17 @@ private async void PickFolderButton_Click(object sender, RoutedEventArgs e) PickFolderOutputTextBlock.Text = "Operation cancelled."; } + //re-enable the button + senderButton.IsEnabled = true; UIHelper.AnnounceActionForAccessibility(sender as Button, PickFolderOutputTextBlock.Text, "FolderPickedNotificationId"); } private async void SaveFileButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario SaveFileOutputTextBlock.Text = ""; @@ -278,6 +306,8 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e) SaveFileOutputTextBlock.Text = "Operation cancelled."; } + //re-enable the button + senderButton.IsEnabled = true; UIHelper.AnnounceActionForAccessibility(sender as Button, SaveFileOutputTextBlock.Text, "FileSavedNotificationId"); } } diff --git a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample1_cs.txt b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample1_cs.txt index 75e59083b..0b6a36aec 100644 --- a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample1_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample1_cs.txt @@ -1,5 +1,9 @@ private async void PickAFileButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickAFileOutputTextBlock.Text = ""; @@ -29,4 +33,7 @@ { PickAFileOutputTextBlock.Text = "Operation cancelled."; } + + //re-enable the button + senderButton.IsEnabled = true; } diff --git a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample2_cs.txt b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample2_cs.txt index 1c8c892b3..e0cacb016 100644 --- a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample2_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample2_cs.txt @@ -1,5 +1,9 @@ private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickAPhotoOutputTextBlock.Text = ""; @@ -32,4 +36,7 @@ { PickAPhotoOutputTextBlock.Text = "Operation cancelled."; } + + //re-enable the button + senderButton.IsEnabled = true; } \ No newline at end of file diff --git a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample3_cs.txt b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample3_cs.txt index 470cd80a3..cf16a867f 100644 --- a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample3_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample3_cs.txt @@ -1,5 +1,9 @@ private async void PickFilesButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickFilesOutputTextBlock.Text = ""; @@ -35,4 +39,7 @@ { PickFilesOutputTextBlock.Text = "Operation cancelled."; } + + //re-enable the button + senderButton.IsEnabled = true; } \ No newline at end of file diff --git a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample4_cs.txt b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample4_cs.txt index d9604c627..14854db9d 100644 --- a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample4_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample4_cs.txt @@ -1,5 +1,9 @@ private async void PickFolderButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario PickFolderOutputTextBlock.Text = ""; @@ -30,4 +34,7 @@ { PickFolderOutputTextBlock.Text = "Operation cancelled."; } + + //re-enable the button + senderButton.IsEnabled = true; } \ No newline at end of file diff --git a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample5_cs.txt b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample5_cs.txt index 02b8c2bd4..f48d59f31 100644 --- a/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample5_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/System/FilePickerSample5_cs.txt @@ -1,5 +1,9 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e) { + //disable the button to avoid double-clicking + var senderButton = sender as Button; + senderButton.IsEnabled = false; + // Clear previous returned file name, if it exists, between iterations of this scenario SaveFileOutputTextBlock.Text = ""; @@ -64,4 +68,7 @@ { SaveFileOutputTextBlock.Text = "Operation cancelled."; } + + //re-enable the button + senderButton.IsEnabled = true; } \ No newline at end of file