<tfoot id='ykqy7'></tfoot>
    • <bdo id='ykqy7'></bdo><ul id='ykqy7'></ul>

        <i id='ykqy7'><tr id='ykqy7'><dt id='ykqy7'><q id='ykqy7'><span id='ykqy7'><b id='ykqy7'><form id='ykqy7'><ins id='ykqy7'></ins><ul id='ykqy7'></ul><sub id='ykqy7'></sub></form><legend id='ykqy7'></legend><bdo id='ykqy7'><pre id='ykqy7'><center id='ykqy7'></center></pre></bdo></b><th id='ykqy7'></th></span></q></dt></tr></i><div id='ykqy7'><tfoot id='ykqy7'></tfoot><dl id='ykqy7'><fieldset id='ykqy7'></fieldset></dl></div>
        <legend id='ykqy7'><style id='ykqy7'><dir id='ykqy7'><q id='ykqy7'></q></dir></style></legend>

        <small id='ykqy7'></small><noframes id='ykqy7'>

        ScrollViewer (UWP) 中的移动图像

        Moving Image in ScrollViewer (UWP)(ScrollViewer (UWP) 中的移动图像)
        <i id='1ISVU'><tr id='1ISVU'><dt id='1ISVU'><q id='1ISVU'><span id='1ISVU'><b id='1ISVU'><form id='1ISVU'><ins id='1ISVU'></ins><ul id='1ISVU'></ul><sub id='1ISVU'></sub></form><legend id='1ISVU'></legend><bdo id='1ISVU'><pre id='1ISVU'><center id='1ISVU'></center></pre></bdo></b><th id='1ISVU'></th></span></q></dt></tr></i><div id='1ISVU'><tfoot id='1ISVU'></tfoot><dl id='1ISVU'><fieldset id='1ISVU'></fieldset></dl></div>

          <legend id='1ISVU'><style id='1ISVU'><dir id='1ISVU'><q id='1ISVU'></q></dir></style></legend>

            <tfoot id='1ISVU'></tfoot>
              <tbody id='1ISVU'></tbody>
          1. <small id='1ISVU'></small><noframes id='1ISVU'>

                • <bdo id='1ISVU'></bdo><ul id='1ISVU'></ul>
                • 本文介绍了ScrollViewer (UWP) 中的移动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Scrollviewer 中有一个 Image...

                  I've got a Image in Scrollviewer...

                  <ScrollViewer x:Name="Scrollster" ZoomMode="Enabled" MinZoomFactor="1" MaxZoomFactor="4"
                            HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" ManipulationMode="All">
                      <Image x:Name="Img" Source="{x:Bind ImgSource}" Stretch="UniformToFill" PointerPressed="Img_PointerPressed"/>
                  </ScrollViewer>
                  

                  当我用鼠标指针拖动图像时,我想移动图像!

                  I want to move Image when I drag image with Mouse Pointer!

                  我试过了:

                  private void Img_PointerPressed(object sender,PointerRoutedEventArgs e)
                  {
                    var p = e.Pointer;
                  }
                  

                  但我无法获得更改滚动查看器位置的指针位置.

                  but I can't get pointer position to change scrollviewer postion.

                  我的代码有什么问题?我做得对吗?

                  What's wrong with my code? Am I doing it right?

                  推荐答案

                  ManipulationMode 应该设置在 Img 控件上.此外,您可能希望指定所需的确切模式而不是 All 以防止不必要的手势处理.

                  The ManipulationMode should be set on the Img control instead. Also, you probably want to specify the exact modes you want rather than All to prevent unnecessary gesture handling.

                  <Image x:Name="Img" Source="{x:Bind ImgSource}" Width="150" Height="150" Stretch="UniformToFill" 
                         ManipulationMode="TranslateX, TranslateY"
                         ManipulationStarted="Img_ManipulationStarted"
                         ManipulationDelta="Img_ManipulationDelta"
                         ManipulationCompleted="Img_ManipulationCompleted">
                      <Image.RenderTransform>
                          <CompositeTransform x:Name="Transform" />
                      </Image.RenderTransform>
                  </Image>
                  

                  根据您上面的描述,我认为同时打开 TranslateXTranslateY 就足够了.然后,您将需要处理 ManipulationStartedManipulationDeltaManipulationCompleted 等操作事件.

                  From your description above, I think turning on both TranslateX and TranslateY should be sufficient. Then you will need to handle manipulation events like ManipulationStarted, ManipulationDelta and ManipulationCompleted.

                  您的大部分逻辑应该在 ManipulationDelta 事件中完成,该事件将在平移过程中多次触发.这是您获取 XY 位置并进行相应设置的地方.

                  Most of your logic should be done in ManipulationDelta event which will be fired multiple times during the progression of the panning. It's where you get the X and Y positions and set them accordingly.

                  这是一个简单的示例.

                  void Img_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
                  {
                      // dim the image while panning
                      this.Img.Opacity = 0.4;
                  }
                  
                  void Img_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
                  {
                      this.Transform.TranslateX += e.Delta.Translation.X;
                      this.Transform.TranslateY += e.Delta.Translation.Y;
                  }
                  
                  void Img_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
                  {
                      // reset the Opacity
                      this.Img.Opacity = 1;
                  }
                  

                  这篇关于ScrollViewer (UWP) 中的移动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                  • <i id='oLtfx'><tr id='oLtfx'><dt id='oLtfx'><q id='oLtfx'><span id='oLtfx'><b id='oLtfx'><form id='oLtfx'><ins id='oLtfx'></ins><ul id='oLtfx'></ul><sub id='oLtfx'></sub></form><legend id='oLtfx'></legend><bdo id='oLtfx'><pre id='oLtfx'><center id='oLtfx'></center></pre></bdo></b><th id='oLtfx'></th></span></q></dt></tr></i><div id='oLtfx'><tfoot id='oLtfx'></tfoot><dl id='oLtfx'><fieldset id='oLtfx'></fieldset></dl></div>
                        <tbody id='oLtfx'></tbody>

                        <legend id='oLtfx'><style id='oLtfx'><dir id='oLtfx'><q id='oLtfx'></q></dir></style></legend>
                        <tfoot id='oLtfx'></tfoot>

                          <bdo id='oLtfx'></bdo><ul id='oLtfx'></ul>

                            <small id='oLtfx'></small><noframes id='oLtfx'>