如何加宽这些 Picker 控件并将它们右对齐?

How do I widen these Picker controls and align them on the right?

我脑子里有很多问题,我意识到有更好的方法可以完成您将看到的大部分内容。随着我学习的时间。

在此特定实例中,我创建了一个带有一些控件的 Frame 元素:

    <Frame Grid.Column="2" Grid.Row="0" HasShadow="False" BorderColor="Black" Margin="10">
        <StackLayout Spacing="10" >
            <StackLayout Padding="10" BackgroundColor="DarkSalmon" HorizontalOptions="FillAndExpand">
                <Label Text="Report Settings"/>
            </StackLayout>

            <Label Text="Starting month:"/>
            <Picker Title="Select month">
                <Picker.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>January</x:String>
                        <x:String>February</x:String>
                        <x:String>March</x:String>
                        <x:String>April</x:String>
                        <x:String>May</x:String>
                        <x:String>June</x:String>
                        <x:String>July</x:String>
                        <x:String>August</x:String>
                        <x:String>September</x:String>
                        <x:String>October</x:String>
                        <x:String>November</x:String>
                        <x:String>December</x:String>
                    </x:Array>
                </Picker.ItemsSource>
            </Picker>
            <StackLayout Orientation="Horizontal">
                <Label Text="Number of months:"/>
                <Picker Title="Number of months" HorizontalOptions="End" HorizontalTextAlignment="Start">
                    <Picker.ItemsSource>
                        <x:Array Type="{x:Type x:String}">
                            <x:String>1</x:String>
                            <x:String>2</x:String>
                            <x:String>3</x:String>
                            <x:String>4</x:String>
                            <x:String>5</x:String>
                            <x:String>6</x:String>
                            <x:String>7</x:String>
                            <x:String>8</x:String>
                            <x:String>9</x:String>
                            <x:String>10</x:String>
                            <x:String>11</x:String>
                            <x:String>12</x:String>
                        </x:Array>
                    </Picker.ItemsSource>
                </Picker>
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Number of publishers to visit each month:"/>
                <Picker Title="Number of publishers" HorizontalOptions="End">
                    <Picker.ItemsSource>
                        <x:Array Type="{x:Type x:String}">
                            <x:String>1</x:String>
                            <x:String>2</x:String>
                            <x:String>3</x:String>
                            <x:String>4</x:String>
                            <x:String>5</x:String>
                        </x:Array>
                    </Picker.ItemsSource>
                </Picker>
            </StackLayout>
            <Label Text="Starting publisher:"/>
            <Picker Title="Number of publishers">
                <Picker.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>Name 1</x:String>
                        <x:String>Name 2</x:String>
                        <x:String>Name 3</x:String>
                        <x:String>Name 4</x:String>
                        <x:String>Name 5</x:String>
                    </x:Array>
                </Picker.ItemsSource>
            </Picker>
        </StackLayout>
    </Frame>

我在 Xamarin 4.8 中使用 Visual Studio for Mac。想使用 5.x 但我得到异常 运行 软件。项目输出为 MacOS。这是我目前看到的:

我想让两个插入 (Number ...) Picker 对象稍宽一些并与右侧对齐。然后标签可以弥补松弛。此刻是错开的,picker变窄了。

我尝试使用 HorizontalOptions 但失败了。

感谢指导。

根据评论中的建议,我能够像这样调整我的 XAML 代码:

<Picker Title="Number of publishers" HorizontalOptions="EndAndExpand" WidthRequest="75">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>1</x:String>
            <x:String>2</x:String>
            <x:String>3</x:String>
            <x:String>4</x:String>
            <x:String>5</x:String>
        </x:Array>
    </Picker.ItemsSource>
</Picker>

我需要使用:

  • HorizontalOptions
  • WidthRequest