Esempio n. 1
0
        /// <summary>
        /// Binds the view model.
        /// </summary>
        /// <param name="view">The view.</param>
        protected virtual void BindViewModel(UIElement view)
        {
            var viewModel = _viewModelLocator.LocateForView(view);

            if (viewModel == null)
            {
                return;
            }

            TryInjectParameters(viewModel, _currentParameter);
            _viewModelBinder.Bind(viewModel, view, null);

            var activator = viewModel as IActivate;

            if (activator != null)
            {
                activator.Activate();
            }
        }
Esempio n. 2
0
        private void OnNavigatedTo(Page page, NavigationEventArgs e, IDictionary <string, object> frameState)
        {
            if (page.DataContext == null)
            {
                var viewModel = _viewModelLocator.LocateForView(page);
                _viewModelBinder.Bind(viewModel, page, null);
            }

            RestorePageState(page, e.NavigationMode, frameState);

            var navigationAware = page.DataContext as INavigationAware;

            if (navigationAware != null)
            {
                navigationAware.OnNavigatedTo(e.Parameter);
            }

            var activator = page.DataContext as IActivate;

            if (activator != null)
            {
                activator.Activate();
            }
        }