I have a custom built menu system in which I would like to load user controls from another project into a tab control on my main project (menu control)
User control Project : foobar Menu system Project : Menu
The function to load them into the tab control:
private void LaunchWPFApplication(string header, string pPath)
{
// Header - What loads in the tabs header portion.
// pPath - Page where to send the user
//Create a new browser tab object
BrowserTab bt = tabMain.SelectedItem as BrowserTab;
bt = new BrowserTab();
bt.txtHeader.Text = header;
bt.myParent = BrowserTabs;
//Load in the path
try
{
Type formType = Type.GetType(pPath, true);
bt.Content = (UserControl)Activator.CreateInstance(formType);
}
catch
{
MessageBox.Show("The specified user control : " + pPath + " cannot be found");
}
//Add the browser tab and then focus
BrowserTabs.Add(bt);
bt.IsSelected = true;
}
And what I send to the function as an example:
LaunchWPFApplication("Calculater", "foobar.AppCalculater");
But every time run, the application complains that the formType is null. I am confused on how to load the user control and curious if I'm sending the correct parameters.