public class NavigateCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
//See http://blogs.msdn.com/b/trevor/archive/2008/08/14/c-warning-cs0067-the-event-event-is-never-used.aspx
public event EventHandler CanExecuteChanged
{
add { }
remove { }
}
/// <summary>
/// 执行跳转
/// </summary>
/// <param name="uri"></param>
public void Execute(object uri)
{
if (uri is String)
{
var root = App.RootFrame;
root.Navigate(new Uri(uri as String, UriKind.RelativeOrAbsolute));
}
}
/// <summary>
/// 清除后退项
/// </summary>
public void ClearBackStack()
{
var root = App.RootFrame;
try
{
while (root.RemoveBackEntry() != null)
{
//do nothing
}
}
catch (Exception e)
{
Debug.WriteLine("backstack cleared(后退项已经移除完)");
}
}
}
windows phone 8 mvvmlight页面跳转类(NavigateCommand)
最新推荐文章于 2022-12-16 08:49:47 发布