Silverlight:画布溢出 [英] Silverlight: Canvas overflows

查看:260
本文介绍了Silverlight:画布溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Canvas,在其中放置一个StackPanel。 StackPanel是水平的,它接受缩略图像的列表。画布有固定的大小。当我把更多的缩略图比Canvas宽度可以容纳,StackPanel应该从画布溢出,所以我可以移动它到当前缩略图的中心。

I have created a Canvas, and within it I placed a StackPanel. The StackPanel is horizontal, and it accepts a list of thumbnailed images. The Canvas has a fixed size. When I put more thumbnails than the Canvas width can hold, the StackPanel is supposed to overflow from the Canvas, so I can move it to center the current thumbnail.

一切正常正确,只有StackPanel的溢出是可见的!有没有办法隐藏它?还是整个方法都错了?

Everything works correctly, only, the StackPanel's overflow is visible! Is there a way to hide it? Or is the entire approach wrong?

这是一个截图。画布是红色的盒子。堆叠面板是蓝色半透明的。

Here is a screenshot. The canvas is the red box. The stackpanel is blue semi-transparent.

http://www.netpalantir.it/static/sl_canvas_overflows.jpg

谢谢!

推荐答案

由于Canvas有固定大小,因此您可以使用 clipping 。基本上你必须做:

Since the Canvas has fixed size, you can use clipping. Basically you have to do:

<Canvas Width="400" Height="300">
    <Canvas.Clip>
            <RectangleGeometry Rect="0, 0, 400, 300"/>
    </Canvas.Clip>
    <!-- your StackPanel here -->
</Canvas> 

以下是有关此主题的一些有用帖子:

Here are few useful posts on the topic:

在Silverlight中裁剪

在Silverlight中裁剪或剪裁

这篇关于Silverlight:画布溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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