This is my XAML View (some code omitted for readability):
<Window ... xmlns:c="http://www.caliburnproject.org">
<Button Content="Close without saving" c:Message.Attach="Close(false)" />
<Button Content="Save and Close" c:Message.Attach="Close(true)" />
</Window>
And here's the code in the ViewModel:
public void Close(bool save)
{
if (save)
{
// save the data
}
TryClose();
}
This doesn't work - of course - because the action parameters "true" and "false" aren't objects or object properties in the XAML. How can I make this work, and send a boolean as an Action parameter in Caliburn Micro?
If you put single quotes around the parameter name, it will properly convert for you.
<Button Content="Close without saving"
c:Message.Attach="Close('false')" />
<Button Content="Save and Close"
c:Message.Attach="Close('true')" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With