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
How can I navigate to a page passing a class business object to it as parameter - using MVVM.
E.g. NavigationServiceProvider.Navigate(new Uri(string.Format("/BookJob/{0}", e.Object.BookJob), UriKind
.Relative));
Where 'BookJob' is an class Object . I get a fail here because NavigationContext only has string.
// Executes when the user navigates to this page. protected override void OnNavigatedTo(NavigationEventArgs e) { if (this.NavigationContext.QueryString.Count > 0) { string id = this.NavigationContext.QueryString["ID"]; if (!string.IsNullOrEmpty(id)) { this.DataContext = new BookJobViewModel(int.Parse(id)); return; } } }
Is there another way achieve this/
Please ignore my previous post and try to do the following.
using System; using System.Windows; using Intersoft.Client.Framework; using Intersoft.Client.Framework.Input; namespace NavigateToPageUsingCommand.ViewModels { public class NavigationServiceProvider { public static void Navigate(Uri uri) { NavigationCommands.Navigate.Execute(uri, (UIElement)ISFocusManager.GetFocusedElement()); } public static void Navigate(Uri uri, bool hasExtraData, object extraData) { NavigationOptions options = new NavigationOptions(uri) { ExtraData = extraData }; NavigationCommands.Navigate.Execute(options, (UIElement)ISFocusManager.GetFocusedElement()); } public static void Navigate(Uri uri, object targetElement) { NavigationCommands.Navigate.Execute(uri, (UIElement)targetElement); } } }
NavigationServiceProvider.Navigate(new Uri("/BookJob", UriKind.RelativeOrAbsolute), true, Object.BookJob)
<Intersoft:UXPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ViewModels="clr-namespace:NavigateToPageUsingCommand.ViewModels" mc:Ignorable="d" xmlns:Intersoft="http://intersoft.clientui.com/schemas" x:Class="NavigateToPageUsingCommand.Views.EditContactProfile" Title="EditContactProfile Page" d:DesignWidth="640" d:DesignHeight="480" NavigatedCommand="{Binding NavigatedCommand}"> <Intersoft:UXPage.DataContext> <ViewModels:EditBookJobViewModel/> </Intersoft:UXPage.DataContext> <Grid x:Name="LayoutRoot"> </Grid> </Intersoft:UXPage>
Hope this helps.
UXPage has NavigatedCommand property. It gets or sets the command to execute when the UXFrame navigates to this page.
You may try to utilize this property for your scenario. First, create a delegate command and set the DataContext for the intended page in this command. Next, we can bind the command for the NavigatedCommand property of the page.
Hope this help.
Thank you for your reply.
I have added binded NavigatedCommand to my command in my ViewModel. The code goes through that command - what I don't know what to do is retrieve the passed (querystring) parameter (business object).
string id = this.NavigationContext.QueryString["ID"]; works fine for string types
How do I get the business class object?
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