1
我有一個定製的菜單系統中,我想從另一個項目加載用戶控件到選項卡控件上我的主項目(菜單控制)啓動用戶控制在一個標籤控件動態
用戶控制項目: foobar的 菜單系統項目:菜單
將其裝入標籤控制功能:
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;
}
而且我發送到功能爲例什麼:
LaunchWPFApplication("Calculater", "foobar.AppCalculater");
但每次運行時,應用程序都會抱怨formType爲空。我很困惑如何加載用戶控件,並好奇我是否發送了正確的參數。