我使用地區導航集成了Silverlight的框架導航時,如下所示:我有我的框架,給我連着區域其中,並設置ContentLoader
到FrameContentLoader
這是我從拿到Karl Shiflett's example:例外「元素已經是另一個元素的子元素。」導航到啓動視圖
<navigation:Frame
x:Name="ContentFrame"
Style="{StaticResource ContentFrameStyle}"
Source="/Home"
Navigated="ContentFrame_Navigated"
NavigationFailed="ContentFrame_NavigationFailed"
prism:RegionManager.RegionName="MainContentRegion">
<navigation:Frame.ContentLoader>
<prism_Regions:FrameContentLoader RegionName="MainContentRegion"/>
</navigation:Frame.ContentLoader>
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="" MappedUri="/MyProject.Views.Home" />
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/MyProject.Views.{pageName}" />
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
</navigation:Frame>
我得到以下異常:「元素已經是另一個元素的孩子。」,這裏的堆棧跟蹤:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.Controls.ContentControl.set_Content(Object value)
at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content)
at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
發生這種情況每當我試圖導航到首頁視圖,而其他所有的導航請求成功完成!爲了確保問題不在視圖本身,我試圖替換首頁與關於這是一個現有的視圖(使其成爲啓動視圖),但問題仍然存在!現在,我可以導航到首頁但不是關於。
什麼可能導致這樣的問題?
PS:即使我刪除了Source
屬性爲Frame
的assignement和默認UriMapper
(第一個)的問題仍然存在。有了這個,我有我訪問的第一個視圖的錯誤,其他人工作正常。