可能重复:
Calling NavigationService.Navigate from Accelerometer.ReadingChanged throws a NotSupportedException
嗨,
如果加速度计触发,我会尝试导航到其他页面:
void accelerometer_ReadingChanged(object sender, AccelerometerReadingEventArgs e)
{
//double X, Y, Z;
if (e.X > 1.5)
{
NavigationService.Navigate(new Uri("/Bars/DetailBar", UriKind.Relative));
}
}
但是,我收到“无效的跨线程访问”错误,我试图通过这样做来解决这个问题:
Dispatcher.BeginInvoke( () => {
NavigationService.Navigate(new Uri("/Bars/DetailBar", UriKind.Relative));
} );
和此:
Deployment.Current.Dispatcher.BeginInvoke( () => {
NavigationService.Navigate(new Uri("/Bars/DetailBar", UriKind.Relative));
} );
但没有任何效果。你能解释我的错误吗?