为什么WP7的全景页面跳转回来的时候更新?
-
26-09-2019 - |
题
我建立一个全球定位系统有关的应用程序,显示除其他计算的坐标。我的演示代码是设置来触发事件的每一秒。
每当我更新主页UI(比如,与计算出的纬度文本框),它工作正常。
的问题是,如果我尝试“轻拂”从一侧到另一侧,以改变页面。而在“轻弹”,如果文本框是更新的过程中,它跳跃的主网页回视图。
的硬类以文本没有视频解释。但是想象一下,点击正控股,并draging全景画面一点点 - 比方说,在接下来的页面偷看但不能翻转呢。好吧,如果文本框是在这段时间进行更新,你会失去你的鼠标点击保持,它会跳回到主画面。
一旦你进入下一个页面,它保持我可以看到从以前的页面溢出更新。没什么大不了的存在。但它只是试图让到下一个页面。
我是新来的WP7 / Silverlight的,所以我一直在尝试使用调度程序,使事情更加敏感。无论我做什么(使用分派或没有),这总是会发生的。所以,我猜测这与用户界面更新的事情。
一个少的代码总是有帮助:
void GeoWatcher_PositionChanged(object sender,
GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => MyPositionChanged(e));
}
void MyPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
{
var model = GeoProcessor.GetPosition(e.Position);
latitude.Text = model.Latitude;
longitude.Text = model.Longitude;
altitude.Text = model.Altitude;
accuracy.Text = model.Accuracy;
direction.Text = model.Direction;
speed.Text = model.Speed;
speedAvg.Text = model.SpeedAvg;
}
当任何这些文本框被更新时,屏幕“跳跃”回主页。那种不愉快的经历。
也许这是正常的吗?有没有挂接到要知道用户正在尝试“滑”到下一个页面的事件?
预先感谢。
解决方案
那么,这种感觉就像一个黑客。但我得到了我想要挂接到一些事件的延迟。如果有,我应该使用(例如鼠标按下/鼠标松开)等事件,让我知道。再次,这是一个黑客但作品。
bool isChangingPage = false;
bool isCompleting = false;
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
this.ManipulationStarted +=
new EventHandler<ManipulationStartedEventArgs>(MainPage_ManipulationStarted);
this.ManipulationCompleted +=
new EventHandler<ManipulationCompletedEventArgs>(MainPage_ManipulationCompleted);
}
void MainPage_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
isChangingPage = true;
}
void MainPage_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
if (isCompleting)
return;
isCompleting = true;
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Thread.Sleep(1000);
isChangingPage = false;
isCompleting = false;
});
}
所有我现在要做的就是检查isChangingPage布尔在我的代码。并将它传递给事件等。
其他提示
我猜,当你在所有这些集.Text
对象直接它们接收焦点(或类似的东西。)
尝试使用数据绑定到设定的值。结果, 我成功做到这一点,以更新的控制上PanoramaItems其不是在视图中的文本。
不隶属于 StackOverflow