I want to define an event for an image object. When I place the mouse on the image, I start an event by pressing the left mouse button and pressing Ctrl. How can I achieve this?
I want to define an event for an image object. When I place the mouse on the image, I start an event by pressing the left mouse button and pressing Ctrl. How can I achieve this?
A way =>
Image img = new Image();
img.Width = 300;
BitmapImage bmpImg = new BitmapImage();
bmpImg.BeginInit();
bmpImg.UriSource = new Uri(@"https://i.ibb.co/BBQ64wy/Flower-Butterfly.jpg", UriKind.RelativeOrAbsolute);
bmpImg.DecodePixelWidth = 300;
bmpImg.EndInit();
img.Source = bmpImg;
img.MouseLeftButtonDown += new MouseButtonEventHandler(img_LeftButtonDown);
(this.Content as Grid).Children.Add(img);
//
private void img_LeftButtonDown(object sender, RoutedEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl))
{
MessageBox.Show("Test", "Information");
}
}
Is the reverse possible?
for example first press keyboard and last press mouse?
4 people are following this question.