How to hide controls when it goes beyond the canvas in WP7?

I am working on a game using WP7 silverlight. Some controls move around, and at some point they go beyond the canvas where they are.

I wonder why they are not hidden?

In window forms, when a control goes beyond the panel, for example, ie:

control.left > panel.width 

he disappears. Is this possible in Silverlight?

thanks..

+6
source share
1 answer

You must use the Clip property.

Next, a button will be shown that will be displayed outside the canvas, since the button width> canvas width:

 <Canvas Width="200" Height="200"> <Button>My button with a lot of text</Button> </Canvas> 

Now, if I add the Clip property, I hide something that goes beyond the clip area:

 <Canvas Width="200" Height="200"> <Canvas.Clip> <RectangleGeometry Rect="0,0,200,200" /> </Canvas.Clip> <Button>My button with a lot of text</Button> </Canvas> 
+5
source

Source: https://habr.com/ru/post/913720/


All Articles