Take the 2-minute tour ×

This is some kind of follow-up with this question.

Say I have a form that the user can fill out, with a ComboBox. There is a button next to the combobox. This button allows to go to a new page where the user can manage the items that were present on the combobox. If the user adds a new item and then navigates back, I want to select this new item in the combobox.

On Android I would use startActivityForResult() to launch a new activity and get the new item back when the form page reappears.

How do I do that in a Metro app?

share|improve this question
Please reserve the metro-ui to Metro design language related questions –  Filip Skakun May 7 '12 at 20:26
add comment

2 Answers

You can override the OnNavigatedTo method in the page and check for e.NavigationMode == NavigationMode.Back to make sure that you navigated back from another page. Then you can check for changes in the content.

share|improve this answer
In the case of a ComboBox that is bound to an ObservableCollection and its content is updated automaticcaly, is there really no other way than using some kind of a hack to select the newest item? No way to get a value back from a page? –  Jonas May 8 '12 at 6:49
You can pass the view model for the ComboBox to the page where you add a new item to the collection and assuming the view model has a property that is bound to the ComboBox's SelectedItem property - you can update that property there. That way when you come back to the page that hosts the ComboBox - the new item will be selected. –  Filip Skakun May 8 '12 at 7:04
Which completely break the concept of each page knowing only what it is supposed to know, and changing the interface on other pages. :/ –  Jonas May 8 '12 at 7:31
Yes, but if the goal of your page is to serve other pages with a way to select/add items - then this is a dialog that does just that and it is its purpose. Otherwise you can play with an EventAggregator/Messenger type of solution, implement a custom navigation system or make your item-adding-control some sort of a dialog instead of a separate page. –  Filip Skakun May 8 '12 at 8:26
add comment

you could create a global variable in App.cs before you navigate to a new page, assign the value to the global variable. after you navigate to the new page, retrieve the value from the global variable.

share|improve this answer
add comment

Your Answer


