0

I am adding menu item to Application bar using this code

ApplicationBar.MenuItems.Insert(0, refreshMenu);

I have 2 other items added from XAML.
But added menu item is adding to the end of list and becoming last menu item insted of being first one.

Is there any way to add menu item to needed index without removing all items and adding in needed order?

EDIT: When I removing menu item from first index, it is removing refresh menu, so the problem is on rendering of menu items.

Thanks

Samvel Siradeghyan
  • 3,523
  • 3
  • 30
  • 49
  • When are you adding the menu items? Try doing it in the `Loaded` event. – Richard Szalay May 20 '12 at 12:42
  • I am adding menu item when one of App bar buttons is clicked, so I cannot do it on Loaded event – Samvel Siradeghyan May 20 '12 at 12:43
  • Woah, that's a really odd UI paradigm thing to come up with. Are you sure that's user friendly? Imagine this in Windows; when you click on a menu item, more items are added to the menu.... not sure about that. – Magnus Johansson May 20 '12 at 14:08
  • Yes I am sure this is user friendly :)) I think you missed one thing. 1 Menu item is adding when you are clicking on Button, not menu. I have a page, where I will show some data. By default it is blank. After user selects button from app bar data is adding to page. And also "refresh" menu item is adding. Ofcourse I could disable "refresh" menu, but in my case adding it is more user friendly then enabling/disabling it. – Samvel Siradeghyan May 20 '12 at 14:31
  • I would argue that adding it is less user friendly. If it is there, but disabled you at least know that it is there. If it is not there one time, but then there the next you have no way of knowing that it way added. Plus, something like refresh can always be enabled, some time it just won't do anything – Shawn Kendrot May 20 '12 at 15:02
  • Thanks for your notes, but refreshing page where the only thing is message, which says "No data set. Please select data" is idiocy. Incorrect and unintuitive work of WP7 app bar is bigger problem then deign of my app. – Samvel Siradeghyan May 20 '12 at 15:42
  • @SamvelSiradeghyan - In that case, your refresh button would be disabled. "Incorrect and unintuitive work of WP7 app bar is bigger problem then deign of my app" <- then just go with it and stop fighting it. – Richard Szalay May 20 '12 at 23:39

2 Answers2

0

It looks like it could be a bug in the framework (it's not really a common scenario). I'd recommend one of the following (in order of recommendation):

  • Keep the item there all the time but disable it when it's not needed (as per Shawn's comment). Built in applications do this already.
  • Swap the entire ApplicationBar to another instance that contains the item (this is a supported scenario)
  • Remove all the items and re-add them in the order you want
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
0

I didn't found any other solution other than I used (remove all items and add then from code each time). So I think the only acceptable way is one I used.

Samvel Siradeghyan
  • 3,523
  • 3
  • 30
  • 49