- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我试图从处理服务器 API 的某个类导航到另一个页面(使用 UriMapping),但它不起作用。这是我的代码:
public void processResponce(item Response)
{
try
{
var token = Response.result.token;
this.setToken("&token=" + token);
Debug.WriteLine(this.apiUrl);
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/listItems", UriKind.Relative));
}
catch
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
var messageFromServer = Response.error.message;
MessageBox.Show(messageFromServer);
Debug.WriteLine(messageFromServer);
});
}
}
SDK 一直说,那个文件不存在。但是,如果我将从某个类调用 Navigate(),附加到 View (fe,MainPage.xaml.cs),则导航成功。谁能帮忙?
UPD. 我有多个 *.xaml 页面,但此类未直接连接到另一个页面。现在,这个类名为“JSON-RPC”。我尝试了不同的方法来解决我的问题(甚至将他命名为“公共(public)部分 JSON-RPC:PhoneApplicationPage”),但是......问题是:如果我从某个类调用 Navigate(),附加到 *.xaml 页面(在解决方案资源管理器它像树一样显示 - *.xaml 页面 -> pagename.xaml.cs),然后它就可以工作了;如果我从我的类 JSON-RPC 调用 Navigate(),那么它总是说“找不到文件”。
UPD2。解决方案:有时我觉得自己是个傻瓜。答案是:
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/listItems", UriKind.Relative));
});
我们需要调用 Dispatcher 来解决这个问题。
最佳答案
确保:
此外:您可以使用 RootFrame 而不是 RootVisual。
这是一个对我有用的例子:
App.Current.RootFrame.Navigate(new Uri("/Pages/Error.xaml?Message=Application error", UriKind.Relative));
关于c# - NavigationService 提示从未附加到任何 View 的类执行 "FileNotFound",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6972549/
我试图在代码中从一个页面导航到另一个页面: if (Game.IsShopping) NavigationService.Navigate("ShopPage.xaml", Game.Curr
我创建了一个 Windows Phone 8.1 项目,其中我在不同的代码段中使用了以下代码: if (this.NavigationService.CanGoBack) { this.Nav
我读到有几个人对此有疑问,所以我想发布一个(有点)优雅的解决方案,我在尝试处理这个问题时想出了。问题是当您在 Silverlight 中创建模板页面并且 ContentControls 没有父 Fra
这似乎是一个非常幼稚的问题,但究竟如何从页面外部获取 NavigationService,例如可能是 View 模型?每个人都说导航应该出现在 View 中,但我一直在想,这不是一个网页,它是一个应用
我想从我的页面捕获 NavigationService.Navigating 事件,以防止用户向前导航。我有一个这样定义的事件处理程序: void PreventForwardNavigation(o
我在 WPF NavigationWindow 中托管了一个小示例应用程序。 它有三个页面(A、B、C)和三个按钮可供用户使用:导航窗口上的后退和前进以及第一页上的下一页。 第一页 A 包含两个单选按
我导航到WP7中的第X页。我的ViewModel中有一个对象(我们称其为香蕉),在该对象中进行NavigationService.Navigate调用。 X页面需要引用香蕉。我怎样才能做到这一点? t
我是 C# 编程的新手,我的代码有问题。我创建了一个按钮并在其上应用了一个事件点击,它通过 NavigationService 技术打开了我项目的另一个页面。 这是脚本: private void c
我正在学习 WP 编码,但遇到无法解决的问题:/ try { NavigationService.Navigate(new Uri("/edit.xaml", UriKind.Relativ
我看到很多关于删除后台堆栈的答案。 但是如何删除前向堆栈? 又名,导航 A,到 B,到 C A -> B -> C 然后我从 C 导航回 B(表单保存,C 关闭 NavigationService.G
设想: 我有一个这样的 NavigationWindow 样式: ... 我通
关于在 xamarin 应用程序中使用 autofac 以及何时使用它们的生命周期范围的初学者问题。 正如 autofac 文档 (https://nblumhardt.com/2011/01/an-
我正在处理的项目是一个基于桌面的 WPF 应用程序。我已经在其中实现了 MVVM 模式。我也在其中使用 Unity IoC 和存储库模式。 我在主详细信息类型场景中遇到问题。我导航到详细信息页面(我已
使用 NavigationService.RemoveBackEntry() 我可以从导航堆栈中删除一个条目。有没有一种方便的方法来删除我的应用程序中的所有后退导航项(场景:我有一个由多个页面组成的注
在我的根 View 模型中,我称之为 await _navigationService.NavigateAsync( "/NavigationPage/Page1of2", useMo
我有一个 Windows Phone 7.5 应用程序,它使用 NavigationService.GoBack() 方法在主页(MainPage.xaml,一个 PhoneApplicationPa
如您所见,我想导航到“ScoreInputDialog.xaml”页面,用户可以在其中键入名称。在此之后,我试图将名称保存到列表中,但它始终为空,因为导航到页面“ScoreInputDialog.xa
如果未设置 access_token,我将尝试导航到 MainPage.xaml。 public Menu() { InitializeCo
在调用NavigationService.GoBack()之前我们需要检查NavigationService.CanGoBack是否为真,但是NavigationService.CanGoBack在什
NavigationService.GoBack();我在 viewmodel 中设置了一个变量,然后我想返回,当我返回时我想使用那个变量,但似乎什么都没有运行,我不想刷新那个页面。 有什么想法吗?
我是一名优秀的程序员,十分优秀!