RoutedEvents: Button Mouse Up Event
<Window x:Class="RoutedEvents.ButtonMouseUpEvent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="RoutedEvents" Height="300" Width="300">
<Grid Margin="5">
<Button Name="cmd" Click="ButtonClick" MouseUp="ButtonMouseUp">Click me.</Button>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace RoutedEvents
{
public partial class ButtonMouseUpEvent : System.Windows.Window
{
public ButtonMouseUpEvent()
{
InitializeComponent();
cmd.AddHandler(Button.MouseUpEvent, new RoutedEventHandler(Backdoor), true);
}
private void ButtonClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("The Button.Click event occurred.");
}
private void ButtonMouseUp(object sender, RoutedEventArgs e)
{
MessageBox.Show("mouse up.");
}
private void Backdoor(object sender, RoutedEventArgs e)
{
MessageBox.Show("The (handled) Button.MouseUp event occurred.");
}
}
}
Related examples in the same category