Note that there are some explanatory texts on larger screens.

plurals
  1. POError using XamlReader.Load() to create Prism Regions from file?
    text
    copied!<p>I'm using Silverlight 5 with Prism and MEF.</p> <p>I am trying to replace my shell at runtime by reading a XAML file, create an UIElement from it and replace the old shell's content with the new UIElement. I am using <code>XamlReader.Load()</code> for this.</p> <p>This works, until I try to create Prism regions.</p> <p>I can create a new Shell with just one prism region in it, but when I have two or more regions in the new shell, all I get is a blank screen in my browser, and no error messages.</p> <p>Is there a way to debug this? And why is this happening?</p> <p>Code:</p> <p>Creating the UIElement and replacing the shell (in Shell.xaml.cs):</p> <pre><code> DependencyObject rootObject = XamlReader.Load(XAMLFileString) as DependencyObject; UIElement customShell = rootObject as UIElement; this.Content = customShell; </code></pre> <p>This works (one region):</p> <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:prism="http://www.codeplex.com/prism"&gt; &lt;StackPanel&gt; &lt;ContentControl prism:RegionManager.RegionName="Region1"/&gt; &lt;/StackPanel&gt; &lt;/UserControl&gt; </code></pre> <p>This also works (two regular content controls):</p> <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:prism="http://www.codeplex.com/prism"&gt; &lt;StackPanel&gt; &lt;ContentControl Content="C1"/&gt; &lt;ContentControl Content="C2"/&gt; &lt;/StackPanel&gt; &lt;/UserControl&gt; </code></pre> <p>but this gives me a blank screen instead (two prism regions):</p> <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:prism="http://www.codeplex.com/prism"&gt; &lt;StackPanel&gt; &lt;ContentControl prism:RegionManager.RegionName="Region1"/&gt; &lt;ContentControl prism:RegionManager.RegionName="Region2"/&gt; &lt;/StackPanel&gt; &lt;/UserControl&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload