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 everybody,
within my project I am using tabbed pages. Every tab should have the same viewmodel. Just the visualization should be different.
Do you have an example for this?
Kind regards,
Fabian
If you want to bind the same view model on multiple views, you need to register the name for each view, differentiating it from the other views. Later, the name will be used as the navigation target. See the following code.
// For iOS[RegisterNavigation("FirstTab")] public partial class FirstViewController : UIViewController<SharedViewModel> { }// For Android[RegisterNavigation("FirstTab")]public class FirstFragment : Fragment<SharedViewModel>{}// For WinPhone[ViewModelType(typeof(SharedViewModel))][RegisterNavigation("FirstTab")]public partial class FirstTab : PhoneApplicationPage{}// For WinRT[ViewModelType(typeof(SharedViewModel))][RegisterNavigation("FirstTab")]public sealed partial class FirstTab : LayoutAwarePage{}
Then while initializing the tab items on your parent's view model, you need to specify the navigation target, which contains the child's view model type and the target name. See the following code.
public class TabViewModel : MultiPageViewModelBase { public TabViewModel() { var items = new List<NavigationItem>(); items.Add(new NavigationItem("First Tab", new NavigationTarget(typeof(SharedViewModel), "FirstTab"))); items.Add(new NavigationItem("Second Tab", new NavigationTarget(typeof(SharedViewModel), "SecondTab"))); items.Add(new NavigationItem("Third Tab", new NavigationTarget(typeof(SharedViewModel), "ThirdTab"))); this.Items = items.ToArray(); } }
Hope this helps. I also attached a sample solution for this scenario.
Feel free to discuss it further if you have any other thought.
Kind Regards,
Jack
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