In my project I have a child window, multiple instances of which can be open at a time. They take in an instance of an object, display information about it, and return information about it. Right now it's working but I have to close the window with the 'X' in the top corner. I would like to be able to close the windows with 'Accept' and 'Cancel' buttons. Should I click accept, I would like to have MVVM Light's messenger send back the appropriate data (which is already functional) and close the window. If I click 'cancel' the changes should be discarded and the window closed. Unfortunately I don't know of a good (and MVVM-friendly) way to close the windows using buttons. I have looked into using commands to no avail and I'm not sure how to go about this. Any help would be appreciated. I don't really know what code to post in this situation...
<Button x:Name="btnAccept"
Grid.Row="2"
Grid.Column="1"
Content="Accept"
Command="{Binding AcceptCommand}"/>
<Button x:Name="btnCancel"
Grid.Row="2"
Grid.Column="2"
Content="Cancel" />
private void ExecuteAcceptCommand()
{
Messenger.Default.Send(Adv.Name);
//Close the window here somehow?
}