【发布时间】:2016-06-06 13:42:48
【问题描述】:
我一直在尝试制作一个有两层的画布。一层水平滚动,第二层在顶部并垂直滚动。 在第二层(垂直滚动的层)中,我堆叠了一个透明网格(或面板)和一个带有信息的面板,这样我们就可以看到该层下的第一层,如果我们向上滚动,我们就会得到信息出现在屏幕上。
这就像一个魅力,除了如果我水平滚动,第一层(下一层)根本不会滚动。如果我们滑动透明网格,垂直滚动不滚动,这不是问题。
这是我的 xaml
<Canvas x:Name="Canvas">
<local:MyPage x:Name="PageContainer"/> <!--This one scrolls horizontally -->
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"
Height="{Binding ActualHeight, ElementName=UcRoot}">
<!--This one scrolls vertically and appears on top -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Height="600" Width="600" Grid.Row="0" x:Name="TransparentGrid" ></Grid>
<Grid x:Name="Information" Background="Azure" Height="1200" Width="600" Grid.Row="1">
</Grid>
</Grid>
</ScrollViewer>
</Canvas>
我在透明网格上尝试了很多东西(例如,将宽度设置为 1,将其移除并将信息网格边距设置为 1200),但网格捕获了事件并且不会中继到我的页面。
我能得到一些帮助吗?
谢谢!
【问题讨论】:
-
设置
ScrollViewer Margin= "0, 0, 0, 25"怎么样?您的图层是透明的,所以可以这样做 -
这不起作用。信息面板需要占据我的画布的整个宽度,它也应该响应手指滑动
-
那你需要在顶层handle
ManipulationDelta事件。如果用户向左/向右擦除,则相应地滚动底层
标签: c# xaml windows-8 microsoft-metro windows-8.1