次のように、Silverlightフレームナビゲーションと統合されたリージョンナビゲーションを使用しています。リージョンをアタッチしたフレームがあり、 KarlShiflettの例から取得したに設定します。ContentLoader
FrameContentLoader
<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)
これは、ホームビューに移動しようとするたびに発生しますが、他のすべてのナビゲーション要求は正常に完了します。ビュー自体に問題がないことを確認するために、Homeを既存のビューであるAboutに置き換えてみました(スタートアップビューにしました)が、問題はまだ存在します!これで、ホームに移動できますが、アバウトには移動できません。
何がそのような問題を引き起こす可能性がありますか?
Source
PS:のプロパティFrame
とデフォルト UriMapper
(最初のプロパティ)の割り当てを削除した後も、問題は解決しません。これにより、最初にアクセスしたビューでエラーが発生し、他のビューは正常に機能します。