当前位置: 首页>>代码示例>>C#>>正文


C# IViewModel.GetParentViewModel方法代码示例

本文整理汇总了C#中IViewModel.GetParentViewModel方法的典型用法代码示例。如果您正苦于以下问题:C# IViewModel.GetParentViewModel方法的具体用法?C# IViewModel.GetParentViewModel怎么用?C# IViewModel.GetParentViewModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IViewModel的用法示例。


在下文中一共展示了IViewModel.GetParentViewModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreserveViewModel

        /// <summary>
        ///     Preserves the view model state.
        /// </summary>
        public IDataContext PreserveViewModel(IViewModel viewModel, IDataContext dataContext)
        {
            Should.NotBeNull(viewModel, "viewModel");
            if (dataContext == null)
                dataContext = DataContext.Empty;
            IDataContext state = PreserveViewModelInternal(viewModel, dataContext);

            GetOrAddViewModelId(viewModel);
            MergeParameters(viewModel.Settings.Metadata, viewModel.Settings.State);
            //Saving parent view model id.
            var parentViewModel = viewModel.GetParentViewModel();
            if (parentViewModel != null)
            {
                var idParent = GetOrAddViewModelId(parentViewModel);
                state.AddOrUpdate(IdParentViewModelConstant, idParent);
            }

            OnViewModelPreserved(viewModel, state, dataContext);
            return state;
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:23,代码来源:ViewModelProvider.cs

示例2: CreateContextNavigateFrom

 protected virtual INavigationContext CreateContextNavigateFrom(IViewModel viewModelFrom, NavigatingCancelEventArgsBase args)
 {
     string idOperation;
     GetViewModelTypeFromParameter(NavigationService.GetParameterFromArgs(args), out idOperation);
     var viewModelTo = idOperation == _currentOperationId ? _navigationTargetVm : null;
     if (viewModelTo == null && viewModelFrom != null && args.NavigationMode == NavigationMode.Back)
         viewModelTo = viewModelFrom.GetParentViewModel();
     return new NavigationContext(NavigationType.Page, args.NavigationMode, viewModelFrom, viewModelTo, this)
     {
         {NavigatingCancelArgsConstant, args},
         {OperationIdConstant, idOperation}
     };
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:13,代码来源:NavigationProvider.cs

示例3: PreserveViewModel

        public IDataContext PreserveViewModel(IViewModel viewModel, IDataContext dataContext)
        {
            Should.NotBeNull(viewModel, "viewModel");
            if (dataContext == null)
                dataContext = DataContext.Empty;

            var preserving = Preserving;
            if (preserving != null)
            {
                var args = new ViewModelPreservingEventArgs(viewModel) { Context = dataContext };
                preserving(this, args);
                dataContext = args.Context ?? DataContext.Empty;
            }
            IDataContext state = PreserveViewModelInternal(viewModel, dataContext);

            GetOrAddViewModelId(viewModel);
            MergeParameters(viewModel.Settings.Metadata, viewModel.Settings.State);
            //Saving parent view model id.
            var parentViewModel = viewModel.GetParentViewModel();
            if (parentViewModel != null)
            {
                var idParent = GetOrAddViewModelId(parentViewModel);
                state.AddOrUpdate(IdParentViewModelConstant, idParent);
            }

            OnViewModelPreserved(viewModel, state, dataContext);

            var preserved = Preserved;
            if (preserved != null)
            {
                var args = new ViewModelPreservedEventArgs(viewModel) { Context = dataContext, State = state };
                preserved(this, args);
                return args.State;
            }
            return state;
        }
开发者ID:FilipHerman,项目名称:MugenMvvmToolkit,代码行数:36,代码来源:ViewModelProvider.cs


注:本文中的IViewModel.GetParentViewModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。