Live Chat Icon For mobile
Live Chat Icon

How do I create in-line event handlers?

Platform: WPF| Category: Coding Techniques

Here are some examples:

Example 1:


animation.Completed += delegate  
              {   
                  // Start the other animation after the end of the previous animation.   
                  index++;   
                  if (lstDefinitions.Count > index)   
                      this.PerformAnimations(index, lstDefinitions);   
              };   

Example 2:


label.MouseDown += (sender, e) =>
        {
            Console.WriteLine('MouseDown:{0}', e.OriginalSource);

            //Not clear why this is needed, but I guess this can effectively bypass
            // any attempt from the parent control to capture the mouse inside MouseDown handler.
            e.Handled = true;
        };

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.