0

我有一个 Xamarin 项目。我在 GameBrain.dll (我与 WPF 项目共享的普通 C# dll)中有我的逻辑,在那里我有一个public static List<Puzzle> Puzzles

然后我有 Xamarin 表单项目,我的视图如下所示:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local ="clr-namespace:GameBrainControl;assembly=GameBrain"
         x:Class="GB.AutoPuzzlesPage">

    <ListView ItemsSource="{x:Static local:Game}">
      <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Label Text="{Binding Name}"/>
            </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>

</ContentPage>

我得到Syntax for x:Static is [Member=][prefix:]typeName.staticMemberName引用我的列表的正确语法是什么???

4

1 回答 1

2

假设:

  • local是命名空间(和程序集)的键,
  • Game是静态类,
  • Puzzlesstatic List

这给出了语法:

<ListView ItemsSource="{x:Static local:Game.Puzzles}">
...
于 2018-10-05T15:11:47.170 回答