PreviewSelectionChanged and child window

2 posts, 0 answers
  1. Josh
    Josh avatar
    18 posts
    Member since:
    May 2008

    Posted 07 Mar 2011 Link to this post


    I am trying to use the PreviewSelectionChanged event on the radtabcontrol to capture a confirmation child window popup, can cancel that selection change in the tab control when I click cancel on the tab control, which should set the e.Handled in the PreviewSelectionChanged event to true.

    But the problem is, the child window will not be shown until the previewselectionchanged event has finished executing.


                CustomerTabs.PreviewSelectionChanged += (s, e) =>
                    if (e.OriginalSource == this.CustomerTabs)
                       var view = new CustomChildWindow();


                        view.Closed += (ss, ee) =>
                                e.Handled = true;


    Please advice...or give me an alternative to prevent selection of tab.
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 10 Mar 2011 Link to this post

    Hello Josh,

    Yes, the childwindow shows after the previewevent completes. Instead, you can use a MessageBox like so:
    private void tabControl_PreviewSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
             if ((sender as RadTabControl).SelectedIndex == 1)
                 MessageBoxResult result = MessageBox.Show("Do you realy want to use tab 1?", "Question", MessageBoxButton.OKCancel);
                 if (result == MessageBoxResult.Cancel)
                     e.Handled = true;
    Could you please let me know if this approach satisfies you or not?

    Best wishes,
    Petar Mladenov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
Back to Top