• Composite Application Guidance for WPF & Silverlight (Prism v2) Reference Implementation migrated to XBap

    Published by on March 13th, 2009 1:43 am under Composite Application Guidance for WPF & SL, p&p, Patterns & Practices, Prism-v2, Windows Presentation Foundation, WPF, XBAP

    1 Comment

    A common interest has come up this last days. A number of questions related to using the Composite Application Guidance for WPF & Silverlight with XBAPs have been asked in the Composite WPF & SL forums at Codeplex:

    Therefore, with my teammates from the P&P Sustained Engineering Team, Matias and Ezequiel we started digging about this and answered them.

    While doing this we found a couple of really interesting things that are required to migrate an existing Composite WPF application to XBAP. You can read about most of them in this blog post.

    Today I set on migrating the Prism-v2 Reference Implementation, to answer yet another one of these questions.

    I will not explain all the changes, but some of them are worth mentioning.

    Main Changes

    The ShellPresenter’s constructor now looks like this, to avoid creating the Shell view twice (the creation should only be  done by setting the StartupUri attribute in the App.xaml file):

    public ShellPresenter()
            {
                View = App.Current.MainWindow.Content as IShellView;
            }

    All region (and regionbehaviours) definitions were  removed from the Shell.xaml file and those same definitions are now performed in the StockTraderRIBootstrapper’s CreateShell method:

    protected override DependencyObject CreateShell()
            {
                ShellPresenter presenter = Container.Resolve<ShellPresenter>();
                Shell shell = presenter.View as Shell;
                NavigationWindow parent = shell.Parent as NavigationWindow;
                parent.ShowsNavigationUI = false;
                //cal:RegionManager.RegionName="{x:Static inf:RegionNames.MainRegion}"
                RegionManager.SetRegionName(shell.PositionBuySellTab,
                    RegionNames.MainRegion);
    
                //cal:RegionManager.RegionName="{x:Static inf:RegionNames.ActionRegion}"
                RegionManager.SetRegionName(shell.ActionContent,
                    RegionNames.ActionRegion);
    
                //cal:RegionManager.RegionName="ResearchRegion"
                RegionManager.SetRegionName(shell.ResearchControl,
                    RegionNames.ResearchRegion);
    
                //<cal:RegionManager.RegionName="{x:Static inf:RegionNames.MainToolBarRegion}"
                RegionManager.SetRegionName(shell.MainToolbar,
                    RegionNames.MainToolBarRegion);
    
                //infBehaviors:RegionPopupBehaviors.CreatePopupRegionWithName="{x:Static inf:RegionNames.SecondaryRegion}"
                RegionPopupBehaviors.RegisterNewPopupRegion(shell,
                    RegionNames.SecondaryRegion);
    
                //infBehaviors:RegionPopupBehaviors.ContainerWindowStyle="{StaticResource WindowRegionStyle}"
                RegionPopupBehaviors.SetContainerWindowStyle(shell,
                    shell.FindResource("WindowRegionStyle") as Style);
    
                return shell;
            }

    Another important change is that now the application’s bootstrapper is created in the OnLoadCompleted method of the application instead of OnStartUp as it used to be done.

    The last really big thing, which allows this application to be run in a Browser is performing the steps in this blog post: Converting EXE Projects to XBAPs.

    XBAP Prism-v2 Reference Implementation Source Code

    The migrated RI does not perform all the operations the WPF RI does. This is due to permission issues.

    Disclaimer

    This code is provided “AS IS” with no warranties, and confers no rights.

    Download

    You can get the source code here:XBap Prism-v2 RI Source Code

    Tags: , , , , , ,

Archives

Categories