Подскажите, почему при клике на эллипсе outerEllipse после обработки события PreviewMouseDown не срабатывают остальные обработчики ? Но если убрать MessageBox.Show(), то они срабатывают:
<StackPanel>
<Button Name="btnClickMe" Height="75" Width = "250" Click ="btnClickMe_Clicked" >
<StackPanel Orientation ="Horizontal">
<Label Height="50" FontSize ="20">Fancy Button!</Label>
<Canvas Height ="50" Width ="100" >
<Ellipse Name = "outerEllipse" Fill ="Green" Height ="25" Width ="50" Cursor="Hand" Canvas.Left="25" Canvas.Top="12" MouseDown="outerEllipse_MouseDown" PreviewMouseDown="outerEllipse_PreviewMouseDown"/>
<Ellipse Name = "innerEllipse" Fill ="Yellow" Height = "15" Width ="36" Canvas.Top="17" Canvas.Left="32"/>
</Canvas>
</StackPanel>
</Button>
</StackPanel>
public partial class WindowsApplication : Window
{
string data = string.Empty;
public WindowsApplication()
{
InitializeComponent();
}
private void btnClickMe_Clicked(object sender, RoutedEventArgs e)
{
data += "Button Clicked\n";
MessageBox.Show(data);
data = string.Empty;
}
private void outerEllipse_MouseDown(object sender, MouseButtonEventArgs e)
{
data += "Outer MouseDown\n";
MessageBox.Show(data);
}
private void outerEllipse_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
data += "Outer PreviewMouseDown\n";
MessageBox.Show(data);
}
}