title: Can anyone provide a concrete example of WPF "visual inheritance" for a dialog box?
body: <p>I am an experienced WinForms developer, relatively new to WPF. I have a large WinForms application that uses a couple different base classes to represent dialog boxes. One such example is AbstractOkCancelDialog. That class contains a panel at the bottom of a dialog, with an Ok and Cancel button on the right side of the panel. I'm trying to determine the best way to handle this, as I realize that WPF doesn't provide visual inheritance.</p>
  
  <p>I don't want to have to create OK and Cancel buttons, and place them, for every dialog in the application.</p>
  
  <p>I have read that the way to do this in WPF is with user controls. I can envision creating a user control with OK and Cancel buttons on it. But I don't want to have to manually place that user control on hundreds of dialogs in my application. I'd really like to have something like this:</p>
  
  <pre><code>public AbstractOkCancelDialog = class(Window)
  {
    protected AbstractOkCancelDialogViewModel _ViewModel;
  
    // AbstractOkCancelDialogViewModel would have commands for OK and Cancel.
    // Every dialog would inherit from AbstractOkCancelDialog, and would use
    // a viewmodel that inherits from AbstractOkCancelDialogViewModel. In 
    // this way, all view models would automatically be connected to the OK
    // and Cancel commands.
  }
  </code></pre>
  
  <p>I've seen some discussion online about how to create the base class. Those discussions explain how there can't be a xaml file associated with the dialog base class, and I understand that restriction. I just can't figure out how to automatically place the user control with the OK and Cancel buttons.</p>
  
  <p>I'm hoping that someone can point me to a sample solution that shows this kind of structure. Thank you in advance!</p>