0

将自定义 RibbonWindow 设置为默认 shell 窗口的过程应该是什么。我们从一个模块中获取这个窗口。我们注册并初始化了它。

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


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

1 回答 1

0

While, it is a little unusual to get the Shell from a module, you could do it exactly the same way it is normally done. Are you using a dependency injection container? I'm going to assume you are:

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

You could just substitute your XamRibbonWindow class for Shell. This way, you do not need to reference the project directly that includes your shell. If you want the ability to resolve more than one shell depending on the modules that are loaded, I would create an interface IShell which XamRibbonWindow implements and register that type with the container.

Edit: Regarding your comments, I would have the module load and on intialize resolve the IRegionManager and call .Add on your region. Or have the shell call NavigateTo if you are using the Navigation interface

Are you using View Discovery or View Injection? (You may need to review the Prism book on UI composition) Also, using MEF, Unity?

于 2012-11-19T15:21:18.067 回答