Get type of object and dynamically set it as the object
<p>Is it possible to get the type of object and dynamically set it as the object. I have several ViewModels that all contain the same Property and want to do something like this</p>

<pre><code>if (this.DataContext is CamerasViewModel)
{
     //Type type = Type.GetType((this.DataContext.ToString());
     object o = Assembly.GetExecutingAssembly().CreateInstance(this.DataContext.GetType().ToString());
     Type type = o.GetType();

     foreach (ButtonViewModel button in (this.DataContext as type).Buttons)
     {
         if (button.DisplayName == this.Content.ToString())
         {
             this.Template = (ControlTemplate)this.FindResource(button.TemplateResource.Substring(0, button.TemplateResource.Length - 3) + "pr");
             break;
         }
     }
 }
</code></pre>

<p>Instead of saying this.DataContext as CamerasViewModel I want to say this.DataContext as THEDYNAMICTYPE</p>

<p>Any suggestions?</p>
