Prism と MEF で Silverlight 5 を使用しています。
XAMLファイルを読み取って実行時にシェルを置き換え、そこからUIElementを作成し、古いシェルのコンテンツを新しいUIElementに置き換えようとしています。私はXamlReader.Load()
これに使用しています。
Prism 領域を作成しようとするまで、これは機能します。
プリズム領域が 1 つだけの新しいシェルを作成できますが、新しいシェルに領域が 2 つ以上ある場合、ブラウザーに空白の画面しか表示されず、エラー メッセージも表示されません。
これをデバッグする方法はありますか? そして、なぜこれが起こっているのですか?
コード:
UIElement の作成とシェルの置き換え (Shell.xaml.cs 内):
DependencyObject rootObject = XamlReader.Load(XAMLFileString) as DependencyObject;
UIElement customShell = rootObject as UIElement;
this.Content = customShell;
これは機能します(1つのリージョン):
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:prism="http://www.codeplex.com/prism">
<StackPanel>
<ContentControl prism:RegionManager.RegionName="Region1"/>
</StackPanel>
</UserControl>
これも機能します (2 つの通常のコンテンツ コントロール)。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:prism="http://www.codeplex.com/prism">
<StackPanel>
<ContentControl Content="C1"/>
<ContentControl Content="C2"/>
</StackPanel>
</UserControl>
しかし、これにより代わりに空白の画面が表示されます (2 つのプリズム領域):
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:prism="http://www.codeplex.com/prism">
<StackPanel>
<ContentControl prism:RegionManager.RegionName="Region1"/>
<ContentControl prism:RegionManager.RegionName="Region2"/>
</StackPanel>
</UserControl>