14

I have a screen where the user can select an option (not a browse gallery as it does not do what is required).

I want to pass the item the user has selected to the pre-made "DetailScreen1" which is used by the browse gallery.

I looked at the browse screen but did not see how it does it as the navigate onselect event is just normal navigation.

Code:

Navigate(DetailScreen1, ScreenTransition.Fade)

I want to do something like

Navigate(DetailScreen1, ScreenTransition.None {Last(listOfStuff)})

Thanks

Zain
  • 1,106
  • 4
  • 12
  • 26

1 Answers1

20

You can use the third parameter of the Navigate function to pass extra parameters to the context of the screen being navigated to. For example, if your first screen has a dropdown and a text input control that you want to pass the values to the next screen, you can use the following expression:

Navigate(DetailScreen1, ScreenTransition.Fade, { text: TextInput1.Value, dropdownChoice: Dropdown1.Selected.Value })

In the DetailScreen1, you can use those context variables as they'll be available.

Here's an example: the dropdown in the first screen contains a list of sections, and after selecting one you would navigate to another page:

Sample result

In the "right arrow", we can set the following OnSelect property:

Navigate(ProductsScreen, ScreenTransition.Fade, { selectedSection: Dropdown1.Selected.Value })

In the ProductsScreen, you can then have a gallery whose items are filtered based on that value that was passed:

Items: Filter(AllProducts, Section = selectedSection)
carlosfigueira
  • 79,156
  • 14
  • 125
  • 167
  • How persistent is this variable? Does it stay in memory or do you have to re-instantiate it if you move to another screen? Like current_user for example...? – Matteo May 04 '17 at 14:32
  • 1
    The third parameter to `Navigate` will set the value of the [context variable](https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/) in the target screen. Context variables will stay in the memory for that screen, until another value is set to the same variable. For example, if you navigate to screen B passing a value {a:1}, the value of `a` in that screen will continue being 1 until another call (to either Navigate to screen B passing `a` as a parameter or to UpdateContext) changes its value. – carlosfigueira May 04 '17 at 20:46