messagebox issue with if

2 posts, 0 answers
  1. Laurensius
    Laurensius avatar
    17 posts
    Member since:
    Jan 2014

    Posted 11 Feb 2014 Link to this post

    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?
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 14 Feb 2014 Link to this post

    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.
  3. DevCraft banner
Back to Top