This is a migrated thread and some comments may be shown as answers.

PreviewSelectionChanged and child window

1 Answer 22 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 08 Mar 2011, 12:04 AM
HI,

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.

eg.

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

                    view.Show();

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

                }
            };

Please advice...or give me an alternative to prevent selection of tab.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 10 Mar 2011, 03:34 PM
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!
Tags
TabControl
Asked by
Josh
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or