我正在为我的应用程序使用 MVVM 设置,并使用滚动查看器来滚动地图。在这张地图上,我有一个单位,当我选择它时我想移动它。但是,当我选择该单元时,我的 ScrollViewer 仍然处于激活状态,有没有办法解决滚动查看器或停用它,以便我可以移动该单元。我已经尝试将 ManipulationModeProperty 更改为 Control,但是当我移动它时,这会导致单位滞后。
我的滚动查看器是:
<ScrollViewer Width="768" Height="380" HorizontalScrollBarVisibility="Hidden">
<View:Map/>
</ScrollViewer>
我应用操作的单位是:
public void ManStart(ManipulationStartedEventArgs e)
{
myScrollViewer.SetValue(ScrollViewer.ManipulationModeProperty, ManipulationMode.Control);
public void ManDelta(ManipulationDeltaEventArgs e)
{
Point fingerPosition = e.DeltaManipulation.Translation;
Unit.x = fingerPosition.X + ChampModelSel.x;
Unit.y = fingerPosition.Y + ChampModelSel.y;
}
public void ManCompleted(ManipulationCompletedEventArgs e)
{
var myScrollViewer = FindParentOfType<ScrollViewer>(ChampViewModel) as ScrollViewer;
myScrollViewer.SetValue(ScrollViewer.ManipulationModeProperty, ManipulationMode.System);
}
我最终自己找到了问题的解决方案。因为我将 ManipulationMode 设置为控制,所以我想我禁用了一些属性,这些属性最终会在您移动对象时产生延迟。因此,我最终尝试在移动对象时制作一个故事板,这解决了问题,并在我选择要移动的对象时给了我一个很好的平滑运动。我所做的就是进入我的 ManDelta:
public void ManDelta(ManipulationDeltaEventArgs e)
{
Point fingerPosition = e.DeltaManipulation.Translation;
Unit.x = fingerPosition.X + ChampModelSel.x;
Unit.y = fingerPosition.Y + ChampModelSel.y;
}
并使用后面的代码添加了一些故事板http://www.buzzfrog.se/index.php/2013/06/create-storyboards-in-code-for-windows-phone/ http://www.buzzfrog.se/index.php/2013/06/create-storyboards-in-code-for-windows-phone/作为指导线。每次我选择对象并激活 ManipulationDelta 时都会发生 ManDelta
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)