none
MultiScaleImage光标到达屏幕边缘触发滚动(高手请进) RRS feed

  • 问题

  • if (lastMousePos.X > 1270)
          msi.ViewportOrigin = new Point(msi.ViewportOrigin.X+(100 / msi.ActualWidth * msi.ViewportWidth),msi.ViewportOrigin.Y);
    if (lastMousePos.X == 0)
          msi.ViewportOrigin = new Point(msi.ViewportOrigin.X - (100 / msi.ActualWidth * msi.ViewportWidth), msi.ViewportOrigin.Y);

    如何控制其向相反方向滚动,及滚动到MultiScaleImage可视的一定范围立即停止?

     

    2010年6月19日 11:02

答案

  • 你好,

         你可以看一下这个文档, http://msdn.microsoft.com/en-us/library/system.windows.controls.multiscaleimage.viewportorigin(VS.95).aspx

        按照文档上的提示:

            private void msi_MouseMove(object sender, MouseEventArgs e)
            {
                var lastMousePos = e.GetPosition(sender as UIElement);
                if (lastMousePos.X > 950 & msi.ViewportOrigin.X<0.4)
                    msi.ViewportOrigin = new Point(msi.ViewportOrigin.X +0.1, msi.ViewportOrigin.Y);
                if (lastMousePos.X < 50 & msi.ViewportOrigin.X>-0.4)
                    msi.ViewportOrigin = new Point(msi.ViewportOrigin.X -0.1, msi.ViewportOrigin.Y);         
            }     

        默认情况下整个ViewPort为0 到 1,可以通过设置ViewPortWidth改变。文档中有详细说明

    2010年6月22日 6:35