Here's how I have my ProWindow coded. I have several button that have their Click method in the xaml.cs file. First, I dragged a Button from the Common WPF Controls Toolbox onto the Window to create a Cancel button, which will just close the window

Then I modified the code in the .xaml file to format it and to add in some properties and events. Simply by typing in Click, Visual Studios offers to create the stub code
<Button x:Name="Cancel" Margin="10,10,0,5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Click="Cancel_Click"
>
<TextBlock Margin="5,0">Cancel</TextBlock>
</Button>
In the xaml.cs file, I have this code to close the window
private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
this.Close();
}