哪个ManipulationMode是用于在UWP中平移自定义控件的套件?

时间:2016-07-27 10:13:34

标签: uwp panning

我有一个自定义控件(CustomPanel),我将ManipulationMode设置为Scale但我无法滚动。哪种ManipulationMode适合滚动和平移?

请找到我的自定义控件。

 <ContentPresenter Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Border>
        <Grid>
            <ScrollViewer x:Name="scrollViewer" 

                          HorizontalScrollBarVisibility="Visible" 
                          VerticalScrollBarVisibility="Visible"
                          HorizontalAlignment="Left" 
                          VerticalAlignment="Top">
                <local:CustomPanel x:Name="customPanel" Height="800" Width="900"
                                   ManipulationMode="Scale"/>
            </ScrollViewer>
        </Grid>
    </Border>
</ContentPresenter>

1 个答案:

答案 0 :(得分:1)

我认为问题是您无法将ManipulationMode设置为CustomPanel,因为CustomPanel位于ScrollViewer内,如果您启用了操作模式在ScrollViwer内部,内部控件将捕获操作事件,并且不再处理它的父ScrollViewer,如果你不处理此控件的Manipulation事件在后面的代码中,除了ScrollViewer不再有效之外,没有任何效果。

但是ScrollViewer可以让用户平移和缩放其内容。所以可能的解决方案是在ScrollViewer

中启用滚动和缩放
<Border>
    <Grid>
        <ScrollViewer x:Name="scrollViewer" 
      HorizontalScrollBarVisibility="Visible" 
      VerticalScrollBarVisibility="Visible"
      HorizontalAlignment="Left"  HorizontalScrollMode="Auto" VerticalScrollMode="Auto"
      VerticalAlignment="Top"
                    ZoomMode="Enabled" >
            <local:CustomPanel x:Name="customPanel" Height="800" Width="900"
               />
        </ScrollViewer>
    </Grid>
</Border>