2012-11-19 26 views
0

將自定義RibbonWindow設置爲默認外殼窗口的過程應該是什麼。 我們從一個模塊獲取這個窗口。我們註冊並初始化了。引導程序中的自定義窗口作爲默認窗口

protected override DependencyObject CreateShell() 
    { 
     return new xamRibbonWindow() as DependencyObject; 
    } 


    protected override void InitializeShell() 
    { 
     base.InitializeShell(); 
     App.Current.MainWindow = (xamRibbonWindow)Shell; 
     App.Current.MainWindow.Show(); 
    } 

回答

0

雖然從模塊中獲取shell是有點不尋常的,但您可以按照與正常情況完全相同的方式進行。你在使用依賴注入容器嗎?我假設你是:

protected override System.Windows.DependencyObject CreateShell() 
{ 
    return ServiceLocator.Current.GetInstance<Shell>(); 
} 

你可以用你的XamRibbonWindow類替換Shell。這樣,您不需要直接引用包含您的shell的項目。如果您想要根據加載的模塊來解析多個shell,我會創建一個XamRibbonWindow實現的接口IShell,並向該容器註冊該類型。

編輯: 關於您的意見,我會模塊加載和初始化解決IRegionManager和調用.Add你的地區。或者如果您使用的是導航界面,請將shell調用NavigateTo

您是使用View Discovery還是View Injection? (您可能需要查看有關UI組成的Prism書籍)另外,使用MEF,Unity?

+0

Shell在Shell中不是模塊。 RibbonWindow是在模塊內部生成的,我想在引導程序中使用它。 – LastBye

+0

和殼牌是主要項目。 – LastBye