저는 Silverlight 5와 Prism 및 MEF를 사용하고 있습니다.XamlReader.Load()를 사용하여 파일에서 프리즘 영역을 만드는 중 오류가 발생 했습니까?
런타임에 셸을 바꾸려면 XAML 파일을 읽고 UIElement를 만들고 이전 셸의 내용을 새 UIElement로 바꾸십시오. 나는 이것을 위해 XamlReader.Load()
을 사용하고 있습니다.
프리즘 영역을 만들려고 할 때까지 작동합니다.
프리즘 영역이 하나만있는 새 셸을 만들 수 있지만 새 셸에 두 개 이상의 영역이 있으면 브라우저에서 빈 화면이 나타나고 오류 메시지가 표시되지 않습니다.
디버깅 할 수있는 방법이 있습니까? 왜 이런 일이 일어나는 것입니까?
UIElement에 작성 및 (Shell.xaml.cs에서) 쉘 교체 :
이DependencyObject rootObject = XamlReader.Load(XAMLFileString) as DependencyObject;
UIElement customShell = rootObject as UIElement;
this.Content = customShell;
이 작동 (한 지역) :이 또한 작동
<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>
(210)
그러나 이것은 나에게 대신 빈 화면 (두 개의 프리즘 지역)를 제공합니다
<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>