locked
How I can add custom event to my custom control in WinRT? RRS feed

  • Question

  • Hello,

    I have created custom CANVAS control and I want to add new event called "completed". How I can add custom event to my control ?

    regards

    Wasim khan

    Wednesday, June 26, 2013 10:58 AM

Answers


  • public sealed partial class MyCanvas : UserControl
    {
       public delegate void CompletedEventHandler(object sender, EventArgs e);
    
       public event CompletedEventHandler Completed;
    
       public MyCanvas()
       {
           // Required to initialize variables
           InitializeComponent();
       }
    
    	private void FireCompleted(EventArgs e)
    	{
    		var handler = Completed;
    		if (handler != null)
    		{
    			handler(this, e);
    		}
    	}
    }

    Use FireCompleted when you need to send the event

    • Proposed as answer by Sachin S Wednesday, June 26, 2013 2:58 PM
    • Marked as answer by wazikhan Wednesday, June 26, 2013 3:49 PM
    Wednesday, June 26, 2013 1:13 PM