我有一个自定义控件(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>
答案 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>