title: WPF: How to close Dialog on button click
body: <p>So I have a editable ViewModel where I wan't it only to be editable through a Dialog window.</p>
  
  <p>Normally the ViewModels view only shows the data but you could press a Edit button which opens up a new Xaml window by calling window.showDialog(). The window takes in the viewModel as it's DataContext, exposes it's properties as editable and has the Save and Cancel commands bound to buttons.</p>
  
  <p>It all works fine but I'm having some problems with this.</p>
  
  <p>Firstly the save command works but it doesn't close the dialog. Secondly it kind of breaks the MVVM because the VM has to know of the EditDialog view to create it.</p>
  
  <p>Also what happens when I click the X close button. I know a Dialog would normally return false as DialogResult but here I'm not handling results.</p>
  
  <p>Has anyone done something similar but elegantly using MVVM?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I also noticed that if I use .ShowDialog I can't edit anything even if I expose as TextBoxes. Is this because of how Modal Dialogs are supposed to work?</p>