【发布时间】:2019-08-30 07:35:54
【问题描述】:
我添加了 3 个按钮,它们都在一个网格中,但我的 ImageButton 没有在我的列中居中:
谁能告诉我这个问题以及如何解决它?
这是 xaml 代码:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Accounting.MainPage">
<StackLayout Margin="3">
<Entry
x:Name="NameEntry"
Placeholder="Enter the Fullname"
/>
<Grid Margin="3,-6,3,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button
Margin="0,0,2,0"
VerticalOptions="Center"
x:Name="AddButton"
Text="Add"
HeightRequest="50"
BackgroundColor="#03A9F4"
TextColor="White"
CornerRadius="10"
Grid.Column="0"
Clicked="AddButton_Clicked"
/>
<ImageButton
Source="add.png"
Grid.Column="2"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="50"
HeightRequest="50"
CornerRadius="50"
/>
<Button
Margin="2,0,0,0"
VerticalOptions="Center"
x:Name="DeleteButton"
Text="Delete"
HeightRequest="50"
BackgroundColor="#f44336"
TextColor="White"
CornerRadius="10"
Grid.Column="3"
Clicked="DeleteButton_Clicked"
/>
</Grid>
<ListView x:Name="WorkersListView" BackgroundColor="#ECEFF1" Margin="2" ItemSelected="WorkersListView_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell TextColor="Black" Text="{Binding WorkerName}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
提前感谢您的帮助。
【问题讨论】:
-
发布完整代码,以便我们更好地帮助您。
标签: c# xaml xamarin.forms