Introduction
This article contains details introduction
about to dynamically navigate user from one view to another view in MVVM. it is
very simple to navigate user to one view to another using code behind.
follow the bellow steps
Steps to navigate without Query string
- Clear the Current Region
- Locally save the reference of current
region.
IRegion region = regionManager.Regions[RegionNames.ContentRegion];
- Create the object of Uri class and in the
constructor pass the View name and kind of uri
var viewUri = new Uri(ViewName, UriKind.Relative);
- Call the RequestNavigate function
region.RequestNavigate(viewUri);
Steps to navigate with Query string
Navigate view with query string is also simple in MVVM, but defferent is that in
the uri constructor u have to mention the query string.
See the bellow steps
Steps
- Clear the Current Region
- Locally save the reference of current
region.
IRegion region = regionManager.Regions[RegionNames.ContentRegion];
- Declare the variable want to pass with
query. Example
string qry="ImageID=1";
- Create the object of Uri class and in the
constructor pass the View name with query string and kind of uri
var viewUri = new Uri(ViewName+qry, UriKind.Relative);
- Call the RequestNavigate function
region.RequestNavigate(viewUri);