代码之家  ›  专栏  ›  技术社区  ›  Ahmed Elashker

Xamarin在平台垂直选项上形成XAML

  •  4
  • Ahmed Elashker  · 技术社区  · 9 年前

    我想做的可能看起来很简单,但我已经找了大约一个小时了,到目前为止没有运气。

    我有以下XAML

    <StackLayout Grid.Row="2" Margin="20,20,20,20">
        <StackLayout.VerticalOptions>
            <OnPlatform x:TypeArguments="x:String">
                <On Platform="Android" Value="CenterAndExpand" />
                <On Platform="iOS" Value="EndAndExpand" />
            </OnPlatform>
        </StackLayout.VerticalOptions>
    </StackLayout>
    

    Cannot assign property VerticalOptions, property does not exists, or is not assignable, or mismatching type between value and property
    

    1 回复  |  直到 9 年前
        1
  •  9
  •   ganchito55    9 年前

    你的问题就在这一行

    <OnPlatform x:TypeArguments="x:String">
    

    LayoutOptions

    <StackLayout Margin="20,20,20,20">
        <StackLayout.VerticalOptions>
            <OnPlatform x:TypeArguments="LayoutOptions">
                <On Platform="Android" Value="CenterAndExpand" />
                <On Platform="iOS" Value="EndAndExpand" />
            </OnPlatform>
        </StackLayout.VerticalOptions>
    </StackLayout>
    

    Xamarin documentation 你可以看到 VerticalOption 是一个 LayoutOption

    语法

    价值

    定义元素布局方式的布局选项。默认值为LayoutOptions。除非另有记录,否则填充。