我正在使用 Xamarin.Forms ,我需要将文字对齐Button
控件上的右侧。
var FirstNameButton = new Button { Text ="First Name "};
任何想法?
答案 0 :(得分:5)
我经常使用Grid,我相信这是实现你想要的一个很好的选择:
<Grid Grid.Column="0" BackgroundColor="{Binding DeleteButtonBackgroundColor}" Padding="5,0,0,0" ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
x:Name="LabelDeleteSelectedExamsPartOne"
Text="{Binding DeleteButtonText}"
TextColor="White"
FontSize="{Binding CustomFontSizeMedium, Source={x:Static constants:DeviceInfo.Instance}}"
HorizontalOptions="Start"
VerticalOptions="Center"/>
<Label Grid.Column="1"
x:Name="LabelDeleteSelectedExamsPartTwo"
Text=""
Style="{StaticResource LabelStyle}"
FontSize="{Binding ExamPageBigIcon, Source={x:Static constants:DeviceInfo.Instance}}"
FontFamily="FontAwesome"/>
<Grid.GestureRecognizers IsEnabled="{Binding DeleteButtonIsEnabled}">
<TapGestureRecognizer
Command="{Binding DeleteSelectedExamsCommand}"/>
</Grid.GestureRecognizers>
</Grid>
答案 1 :(得分:2)
执行此操作的正确方法(与接受的答案相反)是使用自定义渲染器(在这种情况下为List<AddressDto> get addresses => UserStorage.singleton.getUserData().addresses;
类)来覆盖ButtonRenderer
视图中的默认行为每个独立平台的特定项目。
以下是与Android平台有关的示例:
Button
答案 2 :(得分:0)
通过创建Button Renderer创建自定义按钮。您可以执行本机支持的任何操作,而不是Xamarin.Forms。