本文整理汇总了C#中Microsoft.Practices.Prism.Regions.NavigationContext.TryGetNavigationParameter方法的典型用法代码示例。如果您正苦于以下问题:C# NavigationContext.TryGetNavigationParameter方法的具体用法?C# NavigationContext.TryGetNavigationParameter怎么用?C# NavigationContext.TryGetNavigationParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.Prism.Regions.NavigationContext
的用法示例。
在下文中一共展示了NavigationContext.TryGetNavigationParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
/// <summary>
/// Processes the specified navigation context.
/// </summary>
/// <param name="navigationContext">The navigation context.</param>
public void Process( NavigationContext navigationContext )
{
Check.IsNotNull ( navigationContext, "Navigation Context cannot be null." );
var commandName = navigationContext.TryGetNavigationParameter<string> ( _commandNameParameter );
if ( _commandHandlers.ContainsKey ( commandName ) )
{
_commandHandlers[commandName] ( navigationContext );
}
else
{
if ( _defaultHandler != null )
{
_defaultHandler ( navigationContext );
}
if ( _throwExceptionIfDefault )
{
throw new ArgumentException ( "Invalid Command Name:" + commandName );
}
}
}
示例2: FindCommand
private INavigationCommand FindCommand ( NavigationContext navigationContext )
{
var commandName = navigationContext.TryGetNavigationParameter<string> ( "CommandName" );
INavigationCommand commandToExecute;
if ( string.IsNullOrWhiteSpace ( commandName ) )
{
commandToExecute = DefaultCommand;
}
else
{
if ( !commandName.EndsWith ( "Command" ) )
{
commandName += "Command";
}
commandToExecute = _commandsList.ContainsKey ( commandName ) ? _commandsList[commandName] : DefaultCommand;
}
return commandToExecute;
}