title: C# (+WPF) Problems casting generic class to non-generic
body: <p>I must honestly say that I do not really understand much about casting, but I thought this would work.</p>
  
  <p>I have a Generic Class Test:</p>
  
  <pre><code>public class Test&lt;T,U&gt;
  {
       T variable1;
       U variable2;
  
       //etc.
  }
  </code></pre>
  
  <p>I need to use this class in a WPF view, and since you can't create generic views in WPF (how lovely) I thought: lets just use a <code>Test&lt;object, object</code>> for the view, since I am only concerned about working with the string representations of the variables in the view.</p>
  
  <p>So I try:</p>
  
  <pre><code>  Test&lt;Foo, Bar&gt; test = new Test&lt;Foo, Bar&gt;();
    return test as Test&lt;object, object&gt;;
  </code></pre>
  
  <p>But that gives me:</p>
  
  <pre><code>  Error 1   Cannot convert type 'DomainModel.Tests.Test&lt;T,U&gt;' 
    to 'DomainModel.Tests.Test&lt;object,object&gt;' via a reference conversion, boxing
    conversion, unboxing conversion, wrapping conversion, or null type conversion
  </code></pre>
  
  <p>I would think that every object must be castable to object? </p>
  
  <p>Anyhow, I am quite stuck now in how to ever use generic classes in WPF...</p>
  
  <p>Any pointer in the right direction?</p>