在PowerApps中按名称导航到屏幕

时间:2016-05-30 08:41:46

标签: powerapps

假设我的PowerApps应用程序中有一个dropdown控件,其中包含以下项目:

[
    "1. Calculator", 
    "2. Counter", 
    "3. API", 
    "4. Collections", 
    "5. Dropdown", 
    "6. Acceleration", 
    "7. Camera"
]

我想用它的名字导航到一个屏幕。像

这样的东西
Navigate(Nav.Selected.Value, ScreenTransition.Cover)

有可能以某种方式吗? 是否有一个按名称返回控件的函数?

Navigate(GetControl(Nav.Selected.Value), ScreenTransition.Cover)

因为现在我必须使用If功能在应用中导航,如下所示:

Navigate(If(
    "1" in Nav.Selected.Value, Screen1, 
    "2" in Nav.Selected.Value, Screen2, 
    "3" in Nav.Selected.Value, Screen3, 
    "4" in Nav.Selected.Value, Screen4, 
    "5" in Nav.Selected.Value, Screen5, 
    "6" in Nav.Selected.Value, Screen6, 
    "7" in Nav.Selected.Value, Screen7), 
ScreenTransition.Cover)

看起来不太好看。有更优雅的解决方案吗?

1 个答案:

答案 0 :(得分:1)

您可以在此处找到实现方法:https://powerusers.microsoft.com/t5/PowerApps-Forum/Navigate-to-a-screen-by-it-s-name/m-p/2454#M1352

基本上创建一个表并绑定到该表。

添加更多,因为这篇文章被删除声称它没有提供详细信息所以只是克隆上面的链接: 创建一个表格,如:

    Table(
  { Text: "1. Calculator", Screen: Screen1 },
  { Text: "2. Counter", Screen: Screen2 },
  { Text: "3. API", Screen: Screen3 },
  { Text: "4. Collections", Screen: Screen4 },
  { Text: "5. Dropdown", Screen: Screen5 },
  { Text: "6. Acceleration", Screen: Screen6 },
  { Text: "7. Camera", Screen: Screen7 })

然后将下拉列表绑定到该表并使用:

  

导航(Dropdown1.Selected.Screen,ScreenTransition.Fade)