简体   繁体   English

如何扩大这些选取器控件并将它们对齐在右侧?

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

I have lots of questions in my head and I realise there are better ways that much of what you will see can be done.我脑子里有很多问题,我意识到有更好的方法可以完成您将看到的大部分事情。 All with time as I learn.随着时间的推移,我学习了。

In this particular instance I have created a Frame element with some controls:在这个特定的实例中,我创建了一个带有一些控件的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>

I am using Visual Studio for Mac with Xamarin 4.8.我正在使用带有 Xamarin 4.8 的 Visual Studio for Mac。 Want to use 5.x but I get exception running the software.想使用 5.x 但运行该软件时出现异常。 The project output is MacOS. output 项目是 MacOS。 This is what I see at the moment:这是我目前看到的:

在此处输入图像描述

I want to have the two inser (Number...) Picker objects slightly wider and aligned to the right side.我想让两个插入器(数字...) Picker对象稍微宽一些并与右侧对齐。 And then the label can take up the slack.然后 label 可以弥补这一不足。 At the moment it is staggered and the picker narrow.目前它是交错的,选择器很窄。

I tried to use HorizontalOptions but failed.我尝试使用HorizontalOptions但失败了。

Thanks for guidance.谢谢指导。

Based on the advice in the comments I was able to adjust my XAML code like this:根据评论中的建议,我能够像这样调整我的 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>

I needed to use:我需要使用:

  • HorizontalOptions
  • WidthRequest

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java SWT Unified ToolBar(OS X)中右对齐搜索栏 - How do I right align a search bar in a Java SWT Unified ToolBar (OS X) 如何使用图形样式的日期选择器? - How can I do with the Date Picker in Graphical Style? 如何将控件锚定到Xcode的一侧? - How do I anchor controls to one side in Xcode? 如何将进度指示器对齐到 label 的右侧,并使 label 在 SwiftUI 的 VStack 中居中? - How can I align a progress indicator to the right of a label and keep the label centred in a VStack in SwiftUI? 如何在NSTextField中垂直居中对齐文本? - How do I vertically center align text in a NSTextField? 如何在Mac上的Chrome中显示Mac拾色器(滴管)? - How do I present the Mac color picker (eye dropper) in Chrome on Mac? 如何告诉python3寻找正确的模块? - How do I tell python3 to look for the right modules? 如何停止NSTextField阻止NSTableView行的右键单击? - how do i stop NSTextField blocking right clicks for NSTableView rows? 如何在视图的右边缘对齐和锚定 SwiftUI 水平列表? - How to align and anchor SwiftUI horizontal list at right edge of view? 如何在 AppKit 上的自定义 SwiftUI 表单中右对齐项目标签? - How to right-align item labels in a custom SwiftUI form on AppKit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM