✅ Avalonia Message Box
In Avalonia you can create a message box with this tool: https://github.com/AvaloniaCommunity/MessageBox.Avalonia, but how can I see what I clicked on the Message Box. Imagine I had a messagebox with Yes or No as an Option. How can I simply find what option I clicked and do something if i clicked either yes or no?
8 Replies
var result = await box.ShowAsync();
The result here should tell you which button was clicked.The problem is that I don’t know how I can use the var in a if sentence in C#. I want to test if the result =yes Button.The problem I don’t know how the result is written or how I can surely check if the yes button was clicked
Or am I on the wrong path?
The result is an enum
https://github.com/AvaloniaCommunity/MessageBox.Avalonia/blob/master/MsBox.Avalonia/Enums/ButtonResult.cs
GitHub
MessageBox.Avalonia/MsBox.Avalonia/Enums/ButtonResult.cs at master ...
Messagebox for AvaloniaUI. Contribute to AvaloniaCommunity/MessageBox.Avalonia development by creating an account on GitHub.
You can check if the result is a
yes
Button
if (result == ButtonResult.Yes)
Or you can use a switch statment/expressionOk
I will test it
ok, I found my error - everything is alright 😮 thanks 🙂
How can I close this Questioning Thread?
You can close it with
/close
$close
If you have no further questions, please use /close to mark the forum thread as answered