带有滚动背景图像的Listview [英] Listview with scrolling background image

查看:74
本文介绍了带有滚动背景图像的Listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个ListView,看起来像放在架子上的物品.我可以像这样在列表视图上获取架子背景:

I am trying to create a ListView that looks like items sitting on a shelf. I am able to get the shelf background on the list view like so:

<ListView.Background>
    <ImageBrush ImageSource="..\Images\bookshelf.png" AlignmentX="Left" AlignmentY="Top" TileMode="Tile" Stretch="None" ViewportUnits="Absolute" Viewport="0,0,319,203" />
</ListView.Background>

,但是以这种方式执行操作时,背景是静态的,并且当ListView滚动时不会移动.我认为我必须以某种方式将其添加到ListView的滚动视图中,但是我不确定如何.

but when doing it this way the background is static and doesn't move when the ListView scrolls. I figure I have to add this to the scrollview of the ListView somehow but I'm not sure how.

如何添加使用ListView平铺和滚动的图像?

How do I add an image that tiles and scrolls with the ListView?

推荐答案

与其设置ListView的背景,不如尝试创建另一个ScrollViewer,它位于ListView后面并包含图像.滚动ListView时,更新ScrollViewer滚动位置.如果需要,还可以添加视差滚动.

Instead of setting the background of the ListView, try creating another ScrollViewer which is behind the ListView and contains an image. When the ListView is scrolled, update the ScrollViewer scroll position. This will also allow you to add parallax scrolling if you wanted it.

这篇关于带有滚动背景图像的Listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆