Im trying to learn how MouseLeftButtonDown works but no seccuss until now.
When i click on the button, nothing heppends.
<Window x:Class="WpfApplication1.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>
<StackPanel Name="sss">
<Button x:Name="b1" Height="213" MouseLeftButtonDown="sss_MouseDown"/>
</StackPanel>
</Grid>
</Window>
Code behind is :
private void sss_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("3 ->>>>>" + ((Control)sender).Name);
}
From the documentation on this event:
So in short: the button is likely handling this event in order to generate its own
MouseDown
andMouseClick
events. Because the button is marking the event as handled, your own handler isn't being called. Try using one of the more standard events instead.The page also lists a couple of workarounds, but typically I'd steer clear of these and use the more standard solutions.
I had the same problem but used the PreviewMouseLeftButtonDown event instead. That worked.
try simple
PreviewMouseLeftButtonDown
event