如何屏蔽 WPF Wrappanel 的内容?
您好,感谢您的浏览!
背景
这是这个问题的扩展:
其中我询问如何以编程方式在按钮上向上或向下滚动 WrapPanel
的内容 点击。这个问题得到了很好的回答,并且接受的解决方案效果很好。
问题
现在,我在 WrapPanel
中的缩略图在单击按钮时上下滚动,如何屏蔽 WrapPanel
以便图块在超出范围时不会显示框架?例如,我在 WrapPanel
上方有一个 StackPanel
,它包含向上和向下滚动按钮,但是当我向下滚动时,缩略图会覆盖 StackPanel
code> 在它们(和按钮)上方。这是到目前为止我的 XAML,请注意,缩略图在运行时添加到 WrapPanel
中:
使用 Dave Clemmer 的 XAML进行更新
,我的布局更加稳定,但最终我仍然得到 < code>WrapPanel 使其上方的 StackPanel
黯然失色。请查看滚动事件之前和之后拍摄的屏幕截图:
BEFORE SCROLL-
AFTER SCROLL-
更新 2
根据下面 Dave 的评论将画布设置为红色背景。
在滚动之前 -
滚动后 -
Hi and thanks for looking!
Background
This is an extension on this question:
How do I slide child items up or down inside a WPF wrappanel?
In which I asked how I could programattically scroll the contents of a WrapPanel
up or down on a button click. This question was kindly answered and the accepted solution works well.
Problem
Now that my thumbnails in the WrapPanel
scroll up and down on a button click, how do I mask the WrapPanel
so that the tiles don't show when they are outside of frame? For example, I have a StackPanel
above the WrapPanel
that holds the scroll up and down buttons, but when I scroll down, the thumbnails cover up the StackPanel
above them (and the buttons). Here is my XAML so far, please note that the thumbnails are added to the WrapPanel
at runtime:
Update
Using Dave Clemmer's XAML, my layout is steadier, but then I still end up with the contents of the WrapPanel
eclipsing the StackPanel
above it. Please see these screen grabs taken before and after the scroll event:
BEFORE SCROLL-
AFTER SCROLL-
Update 2
Set canvas to red background per Dave's comment below.
BEFORE SCROLL-
AFTER SCROLL-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我不会称之为直观的,但最终,这起作用了:
添加边框就达到了目的。感谢戴夫的所有帮助!
Well, I wouldn't call this intuitive, but in the end, this worked:
Adding the border did the trick. Thanks to Dave for all of your help!
听起来您不想要滚动条(没有
ScrollViewer
)并且希望修复StackPanel
。将StackPanel
和WrapPanel
保留在单独的Grid
行中,例如:It sounds like you do not want scrollbars (no
ScrollViewer
) and want theStackPanel
to be fixed. Keep theStackPanel
andWrapPanel
in separateGrid
rows such as: