title: Generic Argument Constraint Violation?
body: <p>I have declared a base dialog window class that types the datacontext to ensure that the attached viewmodel has the appropriate return type. When I try to use it though I get a generic arguments error: </p>
  
  <blockquote>
    <p>GenericArguments[1],
    'Mocks.MidSoft_Hospitality_ViewModels_Dialogs_ReceiveItemViewModel_32_569724456',
    on
    'Mocks.MidSoft_Hospitality_Views_Dialogs_BaseDialogWindow`2_32_569724456[TResult,TViewModel]'
    violates the constraint of type 'TViewModel'.</p>
  </blockquote>
  
  <p>I can't see why this would be happening</p>
  
  <p>The base dialog window declaration:</p>
  
  <pre><code>public class BaseDialogWindow&lt;TResult, TViewModel&gt; : DialogWindowBase&lt;TResult&gt; where TViewModel: ViewModels.Dialogs.DialogBaseViewModel&lt;TResult&gt;
  {
      public BaseDialogWindow() : base()
      {
  
      }
  
      new public TViewModel DataContext
      {
          get =&gt; this.GetValue(DataContextProperty) as TViewModel;
          set =&gt; this.SetValue(DataContextProperty, value);
      }
  
  }
  </code></pre>
  
  <p>DialogWindowBase:</p>
  
  <pre><code>public class DialogWindowBase&lt;TResult&gt; : Window, IDialog&lt;TResult&gt;
  {
      public DialogWindowBase()
      {
          //Formatting code here
      }
  
      public Result Result { get; set; } = Result.None;
  
      public TResult ReturnData { get; set; }
  
  }
  </code></pre>
  
  <p>The viewModel:</p>
  
  <pre><code>public class ReceiveItemViewModel : ViewModels.Dialogs.DialogBaseViewModel&lt;ReceiveItemResult&gt;
  {
      //View Model Code here
  }
  </code></pre>
  
  <p>and the xaml:</p>
  
  <pre><code>&lt;local:BaseDialogWindow x:Class="MidSoft.Hospitality.Views.Dialogs.ReceiveItemDialog"
                          x:TypeArguments="local:ReceiveItemResult, vm:ReceiveItemViewModel"
                          xmlns:vm="clr-namespace:MidSoft.Hospitality.ViewModels.Dialogs"
                          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                          xmlns:local="clr-namespace:MidSoft.Hospitality.Views.Dialogs"
                          mc:Ignorable="d"
                          d:DataContext="{d:DesignInstance vm:ReceiveItemViewModel, IsDesignTimeCreatable=False}"
                          x:Name="ReceiveStockItemDialog"
                          Height="450" Width="800"&gt;
      &lt;Grid&gt;
      &lt;/Grid&gt;
  &lt;/local:BaseDialogWindow&gt;
  </code></pre>
  
  <p>Code for the dialog:</p>
  
  <pre><code>    public partial class ReceiveItemDialog
      {
          public ReceiveItemDialog()
          {
              InitializeComponent();
          }
      }
  </code></pre>
  
  <p>The error that I referenced above is the only compiler error that I am getting. I would appreciate any insight into this error.</p>
  
  <p>Update: I have now noticed that the application is compiling and running without any exceptions being thrown but the error is still there and the xaml designer is showing it as invalid markup</p>