Value does not fall within the expected range: Map + MVVM + sdk:Frame

5221
3
04-16-2014 04:22 AM
by Anonymous User
Not applicable
Original User: OraKLE

I have a frame that navigates between two Pages: A and B. Page B contains a contentpresenter whose content is data bound to a Map component property on a singleton viewmodel. The map renders well when navigating to page B. However, an exception is thrown when navigating away from page B.

Code: 4004
System.ArgumentException: value does not fall within expected range.

I tried setting the NavigationCacheMode="Required" on both page A+B. The frame that does the navigation has JournalOwnership="OwnsJournal" set.

I tried declaring the Map component xaml in Page B, then data binding to the Layers property with a collection of layers on the viewmodel but this gives me a different error: Element is already a child of another element.

I tried adding a Map component in code behind of page B in the overridden OnNavigatedTo(NavigationEventArgs e) function, then removing it in  OnNavigatedFrom(NavigationEventArgs e), but this still gives me the same exception.

Would anyone kindly advise me on how to use the Map component in an sdk:Frame pagination scenario?
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: dbroux

A map can NOT be displayed twice. That's a limitation that won't exit with the new .Net API.

Additionally a layer can NOT be displayed in 2 maps because UI Elements can only be child of ONE parent.

May be you could try to reset the map to null when leaving a page.
0 Kudos
MofoloMamabolo
New Contributor
A map can NOT be displayed twice. That's a limitation that won't exit with the new .Net API.


I think this is the issue with API 3.2. I reverted to API 3.1 and now I can page to and away from Page B without the exception being thrown.
BillRose
New Contributor III

I can confirm that rolling back to the 3.1 release resolved this same issue for an application with two maps.

0 Kudos