0

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

[
    "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)

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

4

1 回答 1

1

您可以在此处找到实现此目的的方法:https ://powerusers.microsoft.com/t5/PowerApps-Forum/Navigate-to-a-screen-by-it-s-name/mp/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)

于 2016-06-04T17:27:01.447 回答