locked
How to remove an EventHandler?

    Question

  • I have a ListView XAML control, where I've registered an event handler for the ListView.SelectionChanged event:

    list->SelectionChanged += ref new Windows::UI::Xaml::Controls::SelectionChangedEventHandler(this, &MyProgram::MainPage::OnListSelectionChanged);
    How do I go about de-registering/removing this event handler?

    Monday, November 7, 2011 8:17 AM

Answers

  • auto cookie = list->SelectionChanged += ref new Windows::UI::Xaml::Controls::SelectionChangedEventHandler(this, &MyProgram::MainPage::OnListSelectionChanged);
    
    list->SelectionChanged -= cookie;
    
     
    Thanks

    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    • Marked as answer by stugreco Tuesday, November 8, 2011 2:48 AM
    Monday, November 7, 2011 8:25 PM