How to stop an event propagation to a parent control.

3 posts, 1 answers
  1. Young-Lae Chung
    Young-Lae Chung avatar
    6 posts
    Member since:
    Jul 2012

    Posted 14 Dec 2010 Link to this post

    Hi.

    I used two RadExpanders  in application.
    The one is nested in another one (parent / child relationship).

    I want to use a expand (or collapsed) event handler seperately.
    But when child expander's event is fired, the event is propagated to parent's event handler.

    How can I stop it ?

    Please, let me know that. 

    Thanks. 



  2. Young-Lae Chung
    Young-Lae Chung avatar
    6 posts
    Member since:
    Jul 2012

    Posted 15 Dec 2010 Link to this post

    I solved above problem using Handled property of RadRoutedEventArgs.

    In collapsed-event handler of child expander. 
    private void SelectionExpander_Collapsed(object sender, RoutedEventArgs e)
    {
       ((Telerik.Windows.RadRoutedEventArgs)(e)).Handled = true;
    }

    After do that, collapsed-event is not propagated to event handler of parent expander.

    If you have other solutions, please let me know that.

    Thanks.  



  3. DevCraft banner
  4. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 Dec 2010 Link to this post

    Hi Young-Lae Chung,

    Another workaround could be the following: in the PreviewCollapsed event of the parent Expander, you check whether the child Expander is collapsed. And if it is ==> set  e.handled = true again. In addition the two approaches seems to be similar, but they can behave in a different way if you have more child expanders or more parent expanders or both. Feel free to ask if you need further assistance.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top