title: C#: Save a Class Type into a Variable?
body: <p>I'm trying to save some UserControl-Infos into a List like this:</p>
  
  <pre><code>List&lt;UserControlDetails&gt; myList;
  public UserControlDetails 
  {
      string Description { get; set; }
      Type UserControlType { get; set; }
  }
  </code></pre>
  
  <p>Now if I display this List in a ListView, I want to be able to start my UserControl e.g. via the SelectedItem Property like</p>
  
  <pre><code> //SelectedItem.UserControlType = MyMainViewModel;
   var tmp = new SelectedItem.UserControlType(); //This will return a new instance of MainViewModel
  </code></pre>
  
  <p>Any ideas how to do this? Or other ideas?</p>
  
  <p>Thanks a lot!</p>
  
  <p>Cheers</p>
  
  <p>EDIT: Thanks a bunch for the responses. Another question: How do you save the type of a "MaiNViewModel" into a type variable? I get a "Class name is not valid" error</p>
  
  <p>EDIT2: Got it, it's typeof(). I'll now try out the methods and report back as soon as possible</p>