【发布时间】:2013-10-07 08:06:40
【问题描述】:
在页面之间导航时,我按下了开始或搜索按钮,这会将我从应用程序中拉出来。然后当我回到应用程序时。它说 Navigation Service null 或类似的东西。
我怎么能解决它!?
Dispatcher.BeginInvoke(delegate()
{
TextBlock b = (TextBlock)sender;
var CusId = (TextBlock)b.FindName("CusId");
var SCHTime1 = (TextBlock)b.FindName("pschtime");
int intCusId = Convert.ToInt32(CusId.Text);
string ScheduleTime = SCHTime1.Text;
LoginVM.GetCustomerDetail(intCusId);
if (LoginVM.OBCustomerDetail.Count != 0)
{
foreach (var c in LoginVM.OBCustomerDetail)
{
Common.CustomerNetworkId = c.CustomerNetworkId;
Common.intCustomerId = c.Id;
Common.CustomerName = c.Name;
Common.RouteId = c.RouteId.Value;
Common.strReportedTime = DateTime.Now.TimeOfDay.Hours + ":" + DateTime.Now.TimeOfDay.Minutes;
}
getVisitDetailNo();
if (VN == false)
{
myPopup.IsOpen = false;
backstatus = false;
return;
}
if (Common.visitDetailNo == null)
{
return;
}
if (LoginVM.SaveVisitedCustomer(Common.visitDetailNo, Common.strVisitHeaderNo, Common.RouteId, Common.intCustomerId, Common.SPOAccId, Common.intSalesRepId, Common.intAreaSalesManagerAccId, Common.intAreaSalesManagerId, Common.strTransactionDate, ScheduleTime, Common.strReportedTime) == true)
{
//update next Visit Detail No
if (UpdateVisitConfigTable() == true)
{
myPopup.IsOpen = false;
backstatus = false;
Common.urlstring = "/View/frmCustomerMenu.xaml";
NavigationService.Navigate(new Uri("/View/LoadingView.xaml", UriKind.Relative));
configVM = new ConfigViewModel();
//Bind Visited Outlets
bindVisited();
}
else
}
}
});
上面将直接加载到loading.aspx及其代码如下
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Dispatcher.BeginInvoke(delegate() {
NavigationService.Navigate(new Uri(Common.urlstring, UriKind.Relative));
});
错误来自 loading.aspx,即使我离开之前的页面。
![在此处输入图片描述][1]
以黄色突出显示- NavigationService.Navigate(new Uri(Common.urlstring, UriKind.Relative));
Common.urlstring = "/View/frmFirstTimeSync.xaml"
NavigationService = Null 根据错误
http://www.tiikoni.com/tis/view/?id=95ecd7b
我不能发图片,因为我没有足够的声望
【问题讨论】:
-
你需要发布你得到的异常和周围的代码。您是否尝试在页面的构造函数中调用 NavigationService?如果是这种情况,可能会将其移动到受保护的覆盖 void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 方法中
-
但是当按下开始或搜索按钮时这会有帮助吗?因为我使用调度程序来执行我的流程,并在我的流程结束时导航到调度程序内的另一个页面。
-
在您的问题中添加一些代码,任何人都需要查看您正在执行导航的代码块。
-
我已添加代码
-
发布异常消息和引发的点线。
标签: c# windows-phone-7 windows-phone-8