Skip to content

C#, wpf, tab control change

Chethan Chinmay

Asked Jun 29, 2018, 8:11 PM EDT1 answer
Share
LinkedInX
if some function is running, when u want to change other tabs it should not happen, i need to give pop up like "please stop test and change tab"... how to do this 
 
i trid this code but it is continuosly looping and giving pop up 
 
C#
 private async  void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
  if (e.OriginalSource == MainTabControl)
    {
        if (MainTabControl.SelectedIndex != -1)
          {
             if (SharedInfo.TestInProgress)
                {
                   //e.Handled = true;
                   if (MainTabControl.SelectedIndex != 0)
                       {
                          MainTabControl.SelectedIndex = 0;
                     
                             await this.ShowMessageAsync(
                             "Test is in Progress...",
Code
                             "Let the test be completed...");

                          return;
                       }
               }

         }
     }
 }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    let assume that adding task is performing in one tab and u want to go to the subtraction tab before the addition task then you have to make a flag like in the adding function is completed assign one flag(like a static string) then addition completed otherwise set the flag to addintion is not completed after that u can check the flag in your above code it is completed or not
    0