Reputation: 7720
I'm working on a game using WP7 silverlight. Some controls are moving and at some point they get outside the canvas they where in.
I wonder why they are not hidden?
In windows forms when a control gets outside a panel for example, i.e:
control.left > panel.width
it disappears. Can this be possible in silverlight?
thanks..
Upvotes: 6
Views: 945
Reputation: 7243
You should use the Clip property.
The following will show a Button that will show outside of the Canvas because 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, what goes outside of the clip region gets hidden:
<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>
Upvotes: 5