We have followed the steps in the
HelloWorld for WPF Hands on Lab, with some adjustments, to create the HelloWorld as a XBap (WPF Browser Application) in a fashionable manner. The following were the changes made (apart from Windows being Pages, of course):
In the App.xaml file define add the attribute StartupUri="Shell.xaml".
Remove or comment this code from the XAML file: cal:RegionManager.RegionName="MainRegion".
In the CreateShell method of the
Bootstrapper class replace the existing code for the following one:
Window window = App.Current.MainWindow;
Shell shell = window.Content as Shell;
Update the code behind class of the App.xaml file with this one:
public partial class App : Application
// You don't need to override this method
//protected override void OnStartup(StartupEventArgs e)
protected override void OnLoadCompleted(System.Windows.Navigation.NavigationEventArgs e)
Bootstrapper bootstrapper = new Bootstrapper();
After running the application to check if the previous steps worked correctly, the codebehind of the HelloWorldView was modified to this:
// Pre existing namespaces go here…
using Microsoft.Practices.Composite.Regions; // Added this namespace
/// Interaction logic for HelloWorldView.xaml
public partial class HelloWorldView : UserControl
public HelloWorldView(IRegionManager regionManager)
manager = regionManager;
private void Button_Click(object sender, RoutedEventArgs e)
IRegion region = manager.Regions["MainRegion"];//This line returns the expected region.
Application.Current.MainWindow.Title = region.Name; //The correct text is shown.
You might find reading the following thread useful, even though it is not directly related to your situation, deals with an issue with regions:
Activate a different view in a XBAP application
You should also take into account that since XBAPs are not in the scope of the Composite Application Guidance for WPF & SL, some particular things might need to be done differently.
Could you provide more information on your scenario? Are you performing any particular operation before trying to get the regions? Are there any permission issues that you have faced/might be facing?