title: How do I add a UserControl dynamically when all I have is the name of the control in a string format? Silverlight, C#
body: <p>I'm working on calling different user controls, and the only data that I've been given is a string in which to call the user control that I have created. When I know the name, I can hard code and add that control in the code behind and add it dynamically that way, but when the name of the control is being passed to me via a string, I'm having trouble passing that to my usercontrol object and having it not be null... </p>
  
  <p>Here is my code:</p>
  
  <pre><code>string userControlName = "ReportFilterOptions";                
  Type type = this.GetType();
  Assembly assembly = type.Assembly;
  UserControl c = (UserControl)assembly.CreateInstance(type.FullName + "." + userControlName);
  gridReport.Children.Clear();
  gridReport.Children.Add(c);
  </code></pre>