Step 1 : Design of Window
♣ Select label and generate preview mouse down event
♣ Select grid and generate preview mouse down event
♣ Select window and generate preview mouse down event
Step 2 : Mainwindow.xaml.cs code
using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;
namespace TurnelingEvents
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void label1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("This is from Label");
}
private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("This is from Grid");
}
private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("This is from MainWindow");
}
}
}
|