如果我在 StackLayout 中有一个按钮,我可以编写任意多的文本,并且按钮会自动变大。但是,如果我在网格中有两个相邻的按钮,则它将不起作用并且文本会被切断。
<StackLayout>
<Button
FontSize="Large"
Style="{DynamicResource PrimaryColorFullButton}"
Text="{resources:TranslateExtensions ErrorConnectionMessage}"
Command="{Binding ExecuteLoginCommand}" />
<Grid
RowDefinitions="*,50"
ColumnDefinitions="*,*">
<Button
Grid.Row="0"
Grid.Column="0"
Text="{resources:TranslateExtensions NewAccount}"
Command="{Binding ExecuteRegistrationCommand}"
Style="{DynamicResource TransparentFullButtonStyle}">
</Button>
<Button
Grid.Row="0"
Grid.Column="1"
Text="{resources:TranslateExtensions LoginForgotten}"
Command="{Binding ExecuteForgotPasswordCommand}"
Style="{DynamicResource TransparentFullButtonStyle}">
</Button>
</Grid>
</StackLayout>
如何防止文本被截断?
最佳答案
从网格的 RowDefinitions 中删除 ,50
。
<Grid
RowDefinitions="*"
ColumnDefinitions="*,*">
它在 StackLayout 可用空间的底部保留一个高度为 50 的空白/白色矩形,这会切断第 0 行上的按钮。
关于xaml - 按钮文本在网格中被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71739139/