Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用windows phone中的当前偏移量停止滚动_C#_Windows Phone 7_Windows Phone 8 - Fatal编程技术网

C# 使用windows phone中的当前偏移量停止滚动

C# 使用windows phone中的当前偏移量停止滚动,c#,windows-phone-7,windows-phone-8,C#,Windows Phone 7,Windows Phone 8,我在scrollviewer中遇到问题。 情景: 我有一个堆栈面板,里面有一个内容,通过鼠标移动该内容,我会显示一个弹出窗口来重新排列这些内容 问题:当我试图处理鼠标移动的内容弹出显示和滚动发生 预期行为:处理鼠标移动时不应发生滚动 我尝试了“HorizontalScrollBarVisibility=ScrollBarVisibility.Disabled”它工作正常,但它将scrollviewer设置为其初始位置,表示水平偏移设置为零(“0”) 提前感谢。根据我们的讨论,我认为最好的方法是存

我在scrollviewer中遇到问题。 情景:

我有一个堆栈面板,里面有一个内容,通过鼠标移动该内容,我会显示一个弹出窗口来重新排列这些内容

问题:当我试图处理鼠标移动的内容弹出显示和滚动发生

预期行为:处理鼠标移动时不应发生滚动

我尝试了
“HorizontalScrollBarVisibility=ScrollBarVisibility.Disabled
”它工作正常,但它将scrollviewer设置为其初始位置,表示水平偏移设置为零(“0”)


提前感谢。

根据我们的讨论,我认为最好的方法是存储一个类级布尔值,它将决定是否启用滚动。您必须根据自己的需要进行设置(可能与您之前修改可见性的位置相同)

下一步是在scrollviewer上设置一些事件和属性,以便控制它是否滚动。实际上,您只需要修改保存scrollviewer的页面的构造函数,并为
操作启动
事件创建一个处理程序。以下假设控件名为Scroll,并且当控件不应滚动时,变量locked设置为true:

public MainWindow()
      {
         InitializeComponent();
         Scroller.ManipulationStarted += new EventHandler<ManipulationStartedEventArgs>(scroller_ManipulationStarted);
         Scroller.ManipulationMode = ManipulationMode.Control; // Required
      }

      void scroller_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
      {
         if (locked)
         {
            e.Handled = true;
            e.Complete();
         }
      }
public主窗口()
{
初始化组件();
Scroller.manipationstarted+=新事件处理程序(Scroller\u manipationstarted);
Scroller.manufactionMode=manufactionMode.Control;//必需
}
无效滚动条\u操纵开始(对象发送器,操纵开始目标e)
{
如果(已锁定)
{
e、 已处理=正确;
e、 完全();
}
}

我不明白。。。您希望scrollviewer的功能可以滚动,但您希望它被锁定,以便可以从scrollviewer中的对象中处理鼠标移动?这是一个矛盾。你能给出一个真实的使用场景吗?这样我们就可以准确地理解这在你的脑海中应该如何工作?我已经将我的用例描述为“堆栈面板,其中包含一个内容,通过鼠标移动该内容,我会显示一个弹出窗口来重新排列这些内容。”让我解释清楚,堆栈面板有10个按钮。此堆栈面板将是scroll viewer的子级。现在我想通过鼠标移动按钮来重新排列按钮的位置。此时,scrollviewer不应滚动,并且必须保留其当前偏移量,直到重新排列完成。问题是,scrollviewer仅在关闭这些事件时起作用。您如何知道用户是否试图滚动或重新排列按钮?按钮的排列方式在这些按钮之间有一些间隙(空白)。所以,当在那个空间中操作时,意味着应该完成滚动,否则通过按钮操作意味着将完成重新排列