I am currently trying to capture multi-downs from an image on a simple grid. I have no problem launching the event, it just shoots twice. And since clicking on it twice in the end will have a different state (it will show an expanded image), switching to the second press causes problems.
My current code is as follows:
Xaml
<Window x:Class="WpfApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid Background="Transparent" x:Name="MainContent" MouseDown="Generic_MouseDown"> <Image Source="http://www.blogcdn.com/www.engadget.com/media/2011/05/welcome-kansas-city-google-high-speed-internet.jpg" Height="100" Width="100" MouseDown="Generic_MouseDown"/> </Grid> </Window>
the code:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Generic_MouseDown(object sender, MouseButtonEventArgs e) { if (((FrameworkElement)e.Source).GetType() == typeof(System.Windows.Controls.Image)) { Console.Out.WriteLine("image clicked"); } else { Console.Out.WriteLine("grid clicked"); } } }
So, when I click on the image, it starts mousedown twice.
Thanks!
source share