Mr Crazy
Mr Crazy

Reputation: 11

Silverlight 4.0 Click on hidden object

I have a hidden image

<Image x:Name="abc" MouseLeftButtonDown="Handler" Visibility="Collapsed" .../>

I've provided a handler function:

private void Handler(object sender, MouseButtonEventArgs e)
{

}

By my handler never fires. How can I listen to a handler for my hidden image?

Upvotes: 1

Views: 140

Answers (2)

Luke Woodward
Luke Woodward

Reputation: 65034

If you want to be able to click on an Image that isn't visible (though I have no idea why you would want to do so), try using Opacity="0" instead of Visibility="Collapsed".

A control that has a Visibility of Collapsed isn't hidden, it's completely removed from the screen. It's impossible to click on a Collapsed object because it takes up no space on the screen.

Upvotes: 2

Emond
Emond

Reputation: 50692

How can you click on something that is collapsed?

You could wrap the image in a grid with a transparent color, collapse the image and register for the click on the grid.

Upvotes: 1

Related Questions