✅ 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
Kouhai
Kouhai2w ago
var result = await box.ShowAsync(); The result here should tell you which button was clicked.
Daiko Games
Daiko GamesOP2w ago
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?
Kouhai
Kouhai2w ago
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.
Kouhai
Kouhai2w ago
You can check if the result is a yes Button if (result == ButtonResult.Yes) Or you can use a switch statment/expression
Daiko Games
Daiko GamesOP7d ago
Ok I will test it ok, I found my error - everything is alright 😮 thanks 🙂 How can I close this Questioning Thread?
Kouhai
Kouhai7d ago
You can close it with /close
canton7
canton77d ago
$close
MODiX
MODiX7d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?