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



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

请找到我的自定义控件。

 <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>

我认为问题是不能将ManipulationMode设置为CustomPanel,因为CustomPanelScrollViewer内部,如果在ScrollViwer内部启用操作模式,则内部控件将捕获操作事件,不再将其处理到其父ScrollViewer,如果在后面的代码中不为该控件处理Manipulation事件,除了CCD_ 8不再工作之外,不会有任何影响。

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>

最新更新