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

messagebox issue with if

1 Answer 39 Views
MessageBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Laurensius
Top achievements
Rank 1
Laurensius asked on 11 Feb 2014, 04:19 PM
hi,
I'm having a weird behavior to my messagebox 
here is the code
private async void rate_Tap(object sender, System.Windows.Input.GestureEventArgs e)
       {
          string id = (string)((Image)sender).Tag;
          ignoreSelectionChanged = true;
 
          MobileServiceCollection<rating, rating> items;
          IMobileServiceTable<rating> itemTable = App.MobileService.GetTable<rating>();
          items = await itemTable
                      .Where(Table => Table.userid == userId)
                      .ToCollectionAsync();
 
 
          if (id != null)
          {
               for (int i = 0; i < items.Count; i++)
               {
                   if (items[i].itemid == id)
                   {
                       MessageBox.Show("You already giving your rating.");
                       i = items.Count;
                       return;
                   }
                   else
                   {
                       RadMessageBox.Show(new string[] { "very accurate", "not accurate" }, "Acurate?",
                           "Is this information accurate?", closedHandler: (args) =>
                           {
                               int buttonIndex = args.ButtonIndex;
 
                               if (buttonIndex == 0)
                               {
                                   clearListBox();
                                   ratingPlus(id);
                                   saveRating(id);
                                   mvm.LoadDetailData();
                               }
 
                               if (buttonIndex == 1)
                               {
                                   clearListBox();
                                   ratingMinus(id);
                                   saveRating(id);
                                   mvm.LoadDetailData();
                               }
                           });
                   }
               }                   
          }
                      
       }
so what my code above do is i trigger that rate_tap from my listbox that already contain image, and each time i tap it , it suppose to check to my windows azure server and check if there is itemid that equal to id then i will show messagebox saying i already rate it and if there isn't any itemid that equal to id then it will execute radmessagebox.

but it's not working that way, when it check there is itemid that equal to id, it show messagebox and after that it show the radmessagebox... it weird... so where the wrong part?

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 14 Feb 2014, 09:27 AM
Hello Laurensius,

Thanks for writing and for the shared code.

There is one significant difference between the standard Message Box control and ours: the standard message box control blocks the UI thread while it is shown. This is not the case with our message box. As a third-party developer we do not have access to those OS APIs which would allow us to implement similar behavior.

We have a ShowAsync method however which can be awaited. You can try using it in  your scenario or you should be using the standard message box in both cases.

Regards,
Deyan
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
Tags
MessageBox
Asked by
Laurensius
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or