WPF, Image MouseDown Event
Posted
by PrimeTSS
on Stack Overflow
See other posts from Stack Overflow
or by PrimeTSS
Published on 2009-08-07T13:02:02Z
Indexed on
2010/06/05
18:02 UTC
Read the original article
Hit count: 400
wpf
|wpf-controls
I have an control with a mouse down event where Id like to chnage the Image when the image is clicked. But I cant seem to alter ANY of the images properties in the event.
Event
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{
BitmapImage bitImg = new BitmapImage();
bitImg.BeginInit();
bitImg.UriSource = new Uri("./Resource/Images/Bar1.png", UriKind.Relative);
bitImg.EndInit();
((Image)sender).Source = null;
((Image)sender).Width = 100;
((Image)sender).Visibility = Visibility.Hidden;
}
The event does fire, and even the .Visibility property does not alter the image and make it hidden.
What am I doing wrong?
© Stack Overflow or respective owner