[英]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.