本文整理汇总了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;
}
示例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}
};
}
示例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;
}