Hi,
I need a button for two purposes:
- Users can drag the application's window using the button
- Users can simply click the button to toggle visibility of some other element in the window.
The button is a PNG image.
I am trying to do it in the following way:
XAML:
<Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left="177" Canvas.Top="0">
<Button.Template>
<ControlTemplate>
<Image Source="/FootballRssReader;component/images/ball.png" MouseLeftButtonDown="toggleButton_MouseLeftButtonDown"/>
</ControlTemplate>
</Button.Template>
</Button>
C#:
private void toggleButton_Click(object sender, RoutedEventArgs e)
{
contentVisible = !contentVisible;
content.Visibility = contentVisible ? Visibility.Visible : Visibility.Collapsed;
}
private void toggleButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
The problem is that only the window moving works. Clicks on the button don't invoke the Click event handler. When I remove MouseLeftButtonDown event handling from the button's image, the Click event is executed.
Can anybody help me? Is it possible to create such a button?
I tried setting Handled to false in the Image but it didn't help.
Thanks, Michal