During BASTA Austria I have been asked a WPF question. How can I implement a confirmation question that is asked whenever a user checks a CheckBox? Imagine the following dialog:
Our goal is to display an "Are you sure?" message if the user checks "Delete everything!" or hits the "Delete Everything (in Code)" button. There should not be a message box if the user unchecks the "Delete everything!" check box.
XAML Source (Without Confirmation Message)
Here you see the XAML source with which we start:
The code behind file just connects to the view model:
And finally here is the view model (I use Prism's NotificationObject class as the base class to get an implementation of INotifyPropertyChanged):
Add a TriggerAction for Showing Confirmation Message
System.Windows.Interactivity defines a class TriggerAction<T> which we can use to provide a mechanism for adding the confirmation message in XAML. The code is quite simple:
We use an event trigger (mechanism defined in the Expression SDK) to access our TriggerAction in XAML:
September is BASTA! time. It has become a beloved tradition for me to travel in Autumn to Mainz to speak at the BASTA! conference. This year, my workshop, session and keynote topics were .NET, microservices and web dev technology. In this blog post I share my session material and recordings.
Time Cockpit Newsletter
Thanks for your registration! You are almost finished. We need to confirm your email address. To complete the subscription process, please click the link in the email we just sent you.