为什么WP7全景页面更新时会跳回来?
我正在构建一个与 GPS 相关的应用程序,用于显示坐标以及其他计算结果。我的演示代码设置为每秒触发事件。
每当我更新主页 UI(例如,带有计算出的纬度的文本框)时,它都可以正常工作。
问题是,如果我尝试从一侧“轻弹”到另一侧,以更改页面。在“轻拂”过程中,如果文本框要更新,它会将主页跳回到视图中。
如果没有视频,很难用文字解释。但想象一下,点击并按住,然后稍微拖动全景屏幕 - 例如,查看下一页但尚未翻转。好吧,如果文本框在这段时间内更新,您将松开鼠标单击,它会跳回主页。
一旦您到达下一页,它就会保留下来,我可以看到上一页的溢出更新。那里没什么大不了的。但它只是试图进入下一页。
我是 WP7/Silverlight 的新手,所以我一直在尝试使用 Dispatcher 来提高响应速度。无论我做什么(是否使用调度程序),这种情况总是会发生。所以,我猜测这与用户界面的更新有关。
一些代码总是有帮助的:
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;
}
当更新任何这些文本框时,屏幕“跳”回主页。有点糟糕的经历。
也许这很正常?是否有一个事件可以了解用户正在尝试“滑动”到下一页?
提前致谢。
I am building a GPS-related application that displays the coordinates amongst other calculations. My demo code is setup to fire the events every second.
Whenever I update the main page UI (say, a textbox with the calculated Latitude), it works fine.
The problem is if I try to "flick" from one side to the other side, to change the page. While in the process of "flicking", if the textbox was to update, it jumps the main page back into view.
Kind of hard to explain in text without a video. But imagine click-n-holding, and draging the panoramic screen just a little - say, to peek at the next page but not flipping yet. Well, if the textbox was to update during that time, you'd loose your mouse-click-hold, and it would jump back to the main page.
Once you DO get to the next page, it stays and I can see the overflow updating from the previous page. No big deal there. But it's just trying to get to that next page.
I'm new to WP7/Silverlight, so I've been trying to use the Dispatcher to make things more responsive. No matter what I do (using the Dispatcher or not), this always happens. So, I am guessing this has to do with the UI being updated.
A little code always helps:
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;
}
When any of these textboxes are updated, the screen "jumps" back to the main page. Kind of a bad experience.
Maybe that is normal? Is there an event to hook into to knowing that the user is trying to "slide" to the next page?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,这感觉就像是黑客攻击。但我通过参加一些活动得到了我想要的延迟。如果我应该使用其他事件(例如 mousedown/mouseup),请告诉我。再说一遍,这是一个 hack,但有效。
我现在要做的就是检查代码中的 isChangingPage 布尔值。并将其传递给事件等。
Well, this feels like a hack. But I got the delay I wanted by hooking into some events. If there are other events I should be using (e.g. mousedown/mouseup), let me know. Again, this is a hack but works.
All I have to do now is check the isChangingPage boolean in my code. And pass it to events, etc.
我猜当您直接在所有这些对象上设置
.Text
时,它们会接收焦点(或类似的东西)。尝试使用数据绑定来设置值。
我成功地执行了此操作,以更新不在视图中的 PanoramaItems 上的控件文本。
I'd guess that when you set
.Text
on all those objects directly they are receiving focus (or something similar.)Try using databinding to set the values.
I do this successfully to update the text of controls on PanoramaItems which are not in view.