#683 – MouseUp Can Happen in Different Control from MouseDown

You can press a mouse button down while the mouse pointer is located in one control, move the mouse, and then release the mouse button with the mouse pointer located in a different control.  When you do this, the first control will receive the MouseDown event and the second control will receive the MouseUp event.

    <StackPanel>
        <Label Content="Sistine" Background="ForestGreen" Padding="10,20"
               MouseDown="Label_MouseDown" MouseUp="Label_MouseUp"/>
        <Label Content="Buonarroti" Background="Peru" Padding="10,20"
               MouseDown="Label_MouseDown" MouseUp="Label_MouseUp"/>
    </StackPanel>

 

        private void Label_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Label l = sender as Label;
            Console.WriteLine(string.Format("MouseDown on {0}", l.Content));
        }

        private void Label_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Label l = sender as Label;
            Console.WriteLine(string.Format("MouseUp on {0}", l.Content));
        }

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #683 – MouseUp Can Happen in Different Control from MouseDown

  1. Pingback: Dew Drop – November 5, 2012 (#1,436) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: