Skip to content

Commit 4bb3df5

Browse files
authored
Implement ScopedButtonDisabler in Button_Click handlers
Added ScopedButtonDisabler to Button_Click methods to prevent multiple clicks.
1 parent a8cbc6b commit 4bb3df5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

WinUI3Example/WindowedContentDialogPage.xaml.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
#endif
66
#include "App.xaml.h"
77

8+
#include <include/ScopedButtonDisabler.hpp>
89

910
// To learn more about WinUI, the WinUI project structure,
1011
// and more about our project templates, see: http://aka.ms/winui-project-info.
1112

1213
namespace winrt::WinUI3Example::implementation
1314
{
14-
winrt::fire_and_forget WindowedContentDialogPage::Button_Click(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
15-
{
16-
15+
winrt::fire_and_forget WindowedContentDialogPage::Button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
16+
{
17+
ScopedButtonDisabler disabler{ sender };
1718
WinUI3Package::ModernDialogBox dialog;
1819

1920
auto content = dialog.DialogContent();
@@ -33,8 +34,9 @@ namespace winrt::WinUI3Example::implementation
3334

3435
}
3536

36-
winrt::fire_and_forget WindowedContentDialogPage::Button_Click_1(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
37+
winrt::fire_and_forget WindowedContentDialogPage::Button_Click_1(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
3738
{
39+
ScopedButtonDisabler disabler{ sender };
3840
auto const result = co_await WinUI3Example::SampleWindowedContentDialog{}.ShowAsync(
3941
App::AppInstance->window,
4042
winrt::unbox_value<winrt::WinUI3Package::UnderlayMode>(UnderlayModeComboBox().SelectedItem().as<winrt::Microsoft::UI::Xaml::Controls::ComboBoxItem>().Tag())

0 commit comments

Comments
 (0)