Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi can anyone give any example
Posted

Hi, In your viewmodel of the view that contains the frame, create a property to keep the page to navigate like,
C#
private Page _PageToNavigate;
public Page PageToNavigate
{
   get { return _PageToNavigate; }
   set { _PageToNavigate = value; OnPropertyChanged("PageToNavigate"); }
}

And bind this property to Frame's Content property in your view like,
XML
<frame x:name="Browser" content="{Binding PageToNavigate}" xmlns:x="#unknown" />

Now, you just need to assign the page which you want to navigate to the PageToNavigate property. It has OnPropertyChanged defined, so wherever this property is used, everywhere it gets updated with the currently assigned value (i.e., page).
 
Share this answer
 
Comments
mums12345 20-Dec-15 23:56pm    
without fram is it possible ?? in mVVM
VR Karthikeyan 21-Dec-15 3:52am    
You can create separate grids for each page and assign them to a container grid by using its children property.
In Xaml:


Navigate
C#:

private void continueButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.GoForward();
//or
this.NavigationService.Navigate("Second.xaml")
}
in Mvvm:



C#
In Views (We have a Commands.cs file that contains all of these):

public static RoutedCommand NavigateHelp = new RoutedCommand();
In the Page contstructor, you can connect the two:

CommandBindings.Add(new CommandBinding(Commands.NavigateHelp, NavigateHelpExecute));
NavigateHelpExecute can be in the code behind (which is what we do), hook into a ViewModel event handler, or whatever. The beauty of this is that you can disable other navigation like so:

CommandBindings.Add(new CommandBinding(NavigationCommands.Refresh, null));
 
Share this answer
 
Comments
mums12345 21-Dec-15 0:55am    
can you tell me any article that has a complete solution for mvvm navigation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900