C# Generics - can this be done better?
<p>I am trying to get my head around Generics and am refactoring an existing class. I would appreciate feedback on whether it could be done better.</p>

<p>I have a number of ViewModels which implement similar behaviour and could be derived from a common class. An example would be:</p>

<pre><code>public class SelectSupplierViewModel : SelectViewModel&lt;SupplierAModel&gt;
</code></pre>

<p>SupplierAModel is an ISelectModel.</p>

<p>The following class enables a view which displays a menu of items to work with multiple types of data</p>

<pre><code>public class SelectViewModel&lt;T&gt; : ViewModelBase where T : ISelectModel
{
  public Action&lt;SelectViewModel&lt;T&gt;&gt; OnItemSelected;

  public IEnumerable&lt;T&gt; Selections { get; set; }  

  public T SelectedItem
  {
      get { return null; }
      set {
          RaisePropertyChanged();
          OnItemSelected?.Invoke(this);
      }
  }

  .
  .
  .
</code></pre>

<p>OnItemSelected is hooked up to a handler in a separate class.  It is executed on the earlier 'Invoke':</p>

<pre><code>private void OnSupplierSelected(SelectViewModel&lt;SelectAModel&gt; viewModel)
{
    // When I inspect viewModel I can see that viewModel is a 
    // SelectSupplierViewModel, and I need to access properties on 
    // this.

    // Is it possible to do so without casting viewModel to    
    // SelectSupplierViewModel?
}
</code></pre>

<p>It was not possible to have a method accepting a SelectSupplierViewModel as the SelectViewModel class is expecting SelectViewModel.</p>

<p>Thankyou!</p>