I have a WPF Window that gets filled with multple images, I am trying to find a way to blur all the images the mouse is NOT hovering over.
I am using this event to effect images that I am hovering over:
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.OriginalSource is Image)
{
((Image)e.OriginalSource).Effect = new BlurEffect();
}
}
This is how I created the images
StackPanel imgStkpnl = new StackPanel();
foreach (var urll in Tools.MyGlobals.GoogleImageURLs)
{
var image = new System.Windows.Controls.Image();
var fullFilePath = urll;
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
try
{
bitmap.UriSource = new Uri(fullFilePath, UriKind.Absolute);
bitmap.EndInit();
image.Source = bitmap;
image.Stretch = Stretch.Uniform;
image.HorizontalAlignment = HorizontalAlignment.Left;
imgStkpnl.Children.Add(image);
}
catch { }
}
If anyone knows a way to effect all the other images that would be a great help, I'm a big newby so go easy on me :) Thanks
I was able to achieve your desired effect using this XAML:
Following on from your comment, to leave the image unblurred, just remove the
MouseLeave
event trigger