Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Best way to move a view from one region to another?

$
0
0
Based on my understanding, you would like to move an active View from one Region to another, and erase it from the first one.

Therefore, you could use a button to fire a moveView command and then, the commandHandler would remove the activeView from the first Region, and add it on the second one.
The CommandHandler implementation may look like this:
publicvoid MoveViewCommandHandler()
{
    var viewToMove = this.regionManager.Regions["FirstRegion"].ActiveViews.FirstOrDefault();
    
    // Navigate on First region in order to load a View after the active View is movedthis.regionManager.Regions["FirstRegion"].RequestNavigate(new Uri("MainDefaultView", UriKind.Relative)); 

     this.regionManager.Regions["FirstRegion"].Remove(viewToMove);
     
     // Adding the View into the Second Regionthis.regionManager.Regions["SecondRegion"].add(viewToMove);
     this.regionManager.Regions["SecondRegion"].RequestNavigate(New Uri("MyMovedView", UriKind.Relative));
}
If the View you would move is not active, then you would look for it in the Region's Views list and RequestNavigate() on the First Region would not be needed.


I hope this helps,
Regards.

Gabriel Ostrowsky
https://blogs.southworks.net/gostrowsky

Viewing all articles
Browse latest Browse all 1878

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>