iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi
How do I navigate to another page using mvvm - so behind a command button I run some code (in viewmodel), then on finishing the code I want close the current page and move to a new page.
Thanks
ClientUI already includes several predefined commands for navigation that you can use in your application such as Navigate command.
The following code example shows how to navigate to a page using Navigate command assigned in a button.
<Intersoft:UXPage xmlns:Intersoft="http://intersoft.clientui.com/schemas"> <StackPanel> <Intersoft:UXButton Content="Navigate to Home" Command="Intersoft:NavigationCommands.Navigate" CommandParameter="/Home" /> </StackPanel> </Intersoft:UXPage>
You might want to try to bind the CommandParameter property as shown in the following snippet code.
View: MainPage.xaml
... <Intersoft:UXButton Content="Navigate to Home" Command="Intersoft:NavigationCommands.Navigate" CommandParameter="{Binding UriNavigateTo}" /> ...
ViewModels: MainPageViewModel.cs
public class MainPageViewModel : ViewModelBase { public MainPageViewModel() { this._uriNavigateTo = new Uri("/UXPage1", UriKind.RelativeOrAbsolute); } private Uri _uriNavigateTo; public Uri UriNavigateTo { get { return _uriNavigateTo; } set { _uriNavigateTo = value; OnPropertyChanged("UriNavigateTo"); } } }
Or bind the Command property as shown in the following.
... <Intersoft:UXButton Content="Navigate to Home" Command="{Binding NavigateAction}" /> ...
public class MainPageViewModel : ViewModelBase { public MainPageViewModel() { this.NavigateAction = new DelegateCommand(NavigateCommandAction, CanNavigateAction); } public DelegateCommand NavigateAction { get; private set; } private bool CanNavigateAction(object parameter) { return true; } private void NavigateCommandAction(object parameter) { NavigationServiceProvider.Navigate(new Uri("/Blank", UriKind.Relative)); } }
Hope this helps.
just what I was looking for - thanks. Is this in the documentation - have I overlooked?
Glad to hear the good news.
The complete predefined commands for navigation are available in the ClientUI documentation. Please open ClientUI Documentation (start > All Programs > Intersoft WebUI Studio 2011 R2 SP1 > WebUI Studio for Silverlight 5 > Intersoft ClientUI Documentation) and check the Navigation Commands in the Navigation Overview topic; or check out the live version in here.
Should you need further assistance or run into any problems regarding our controls, feel free to post it into our community site. We would be happy to assist you again.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname