C
C#2mo ago
Daiko Games

✅ 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
Kouhai2mo ago
var result = await box.ShowAsync(); The result here should tell you which button was clicked.
Daiko Games
Daiko GamesOP2mo 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
Kouhai2mo 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
Kouhai2mo 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 GamesOP2mo ago
Ok I will test it ok, I found my error - everything is alright 😮 thanks 🙂 How can I close this Questioning Thread?
Kouhai
Kouhai2mo ago
You can close it with /close
canton7
canton72mo ago
$close
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?