我正在尝试在我的应用程序中实现漂亮的水平滚动gridview。我已经使用Q42.WinRT library这样实现了它:
<Canvas>
<StackPanel Orientation="Horizontal" Height="768">
<StackPanel.RenderTransform>
<CompositeTransform
TranslateX="{Binding ElementName=MyScrollViewer, Path=HorizontalOffset, Converter={StaticResource ParallaxConverter}}" />
</StackPanel.RenderTransform>
<Image Source="/Assets/3.jpg" Width="1366" Stretch="UniformToFill"/>
<Image Source="/Assets/1.jpg" Stretch="UniformToFill"/>
<Image Source="/Assets/2.jpg" Stretch="UniformToFill"/>
</StackPanel>
</Canvas>
<ScrollViewer
x:Name="MyScrollViewer"
HorizontalScrollMode="Enabled"
HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled"
VerticalAlignment="Center"
Height="768">
<GridView>
//...my gridview goes here
</GridView> </ScrollViewer>
一切正常,但在我的应用程序中我需要使用语义缩放,我发现当放入ScrollViewer时语义缩放不能正常工作。
一般来说,我在互联网上找到的所有parallactic背景解决方案都在滚动浏览器上实现了某种功能,这对我来说是不幸的,因为我无法使用它。
有人能想出另一种达到预期效果的方法吗?
答案 0 :(得分:2)
通常将GridViews放在ScrollViewer中并不是一个好主意,因为它们内部已经有ScrollViewers ...
您应该将2个GridView放在SemanticZoom中。
也许您可以编辑GridView的模板并在其中放置视差背景 - 可能是一个Canvas,其中包含一些响应GridView上的ViewChanged事件的内容。
编辑*
你激励我尝试为Toolkit编写一个ParallaxBackgroundBehavior。 :)
您可以看到早期版本here。还有sample included。