Beispiel #1
0
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            if (viewModelState == null)
            {
                return;
            }

            // Try to populate address and payment method controls with default data if available
            ShippingAddressViewModel.SetLoadDefault(true);
            BillingAddressViewModel.SetLoadDefault(true);
            PaymentMethodViewModel.SetLoadDefault(true);

            // This ViewModel is an example of composition. The CheckoutHubPageViewModel manages
            // three child view models (Shipping Address, Billing Address, and Payment Method).
            // Since the FrameNavigationService calls this OnNavigatedTo method, passing in
            // a viewModelState dictionary, it is the responsibility of the parent view model
            // to manage separate dictionaries for each of its children. If the parent view model
            // were to pass its viewModelState dictionary to each of its children, it would be very
            // easy for one child view model to write over a sibling view model's state.
            if (e.NavigationMode == NavigationMode.New)
            {
                viewModelState["ShippingViewModel"]      = new Dictionary <string, object>();
                viewModelState["BillingViewModel"]       = new Dictionary <string, object>();
                viewModelState["PaymentMethodViewModel"] = new Dictionary <string, object>();
            }

            ShippingAddressViewModel.OnNavigatedTo(e, viewModelState["ShippingViewModel"] as Dictionary <string, object>);
            BillingAddressViewModel.OnNavigatedTo(e, viewModelState["BillingViewModel"] as Dictionary <string, object>);
            PaymentMethodViewModel.OnNavigatedTo(e, viewModelState["PaymentMethodViewModel"] as Dictionary <string, object>);
            base.OnNavigatedTo(e, viewModelState);
        }
Beispiel #2
0
        public override async void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary <string, object> viewModelState)
        {
            if (await _accountService.VerifyUserAuthenticationAsync() == null)
            {
                return;
            }

            var addressId = navigationParameter as string;

            HeaderLabel = string.IsNullOrWhiteSpace(addressId)
                              ? _resourceLoader.GetString("AddShippingAddressTitle")
                              : _resourceLoader.GetString("EditShippingAddressTitle");

            ShippingAddressViewModel.OnNavigatedTo(navigationParameter, navigationMode, viewModelState);
        }