我在ViewCell中有一个按钮......
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ConnectionCrew.UI.Shared.Appointments.CompletionFormMain">
<ViewCell.View>
<Grid Margin="8, 16, 8, 16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackLayout BackgroundColor="#bdbdbd" Padding="1">
<Editor x:Name="txtBxShiftNotes" BackgroundColor="White" Grid.Row="0" HeightRequest="100" />
</StackLayout>
<Button x:Name="btnSubmit" VerticalOptions="End" Grid.Row="1" HorizontalOptions="FillAndExpand" Text="Confirm Attendence" BackgroundColor="Lime" TextColor="White" HeightRequest="50" />
</Grid>
</ViewCell.View>
</ViewCell>
正在发生两件令人不快的事情。
1)包含ViewCell的底部位于按钮文本的正下方 - 就像文本的基线与单元格的底部对齐一样。
2)如果我点击按钮,其点击事件不会触发,整个单元格会闪烁。除非我单击文本上方 - 在这种情况下没有闪烁,并且单击事件被引发。
如何解决这些问题?我不希望没有闪烁,正确的对齐和正确的命中测试。
答案 0 :(得分:0)
我不知道你的问题,但我建议:
Grid.Row
和Grid.Column
属性添加到StackLayout
控件Grid.Row
属性(它位于StackLayout中,因此StackLayout应具有Row和Column属性)Grid.Column
属性添加到Button
控件答案 1 :(得分:0)
我将边距移动到子元素......
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ConnectionCrew.UI.Shared.Appointments.CompletionFormMain">
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackLayout Margin="8, 8, 8, 0" Grid.Row="0" BackgroundColor="#bdbdbd" Padding="1">
<Editor x:Name="txtBxShiftNotes" BackgroundColor="White" HeightRequest="100" />
</StackLayout>
<Button Margin="8, 0, 8, 8" x:Name="btnSubmit" VerticalOptions="CenterAndExpand" Grid.Row="1" HorizontalOptions="FillAndExpand" Text="Confirm Attendence" BackgroundColor="Lime" TextColor="White" HeightRequest="50" />
</Grid>
</ViewCell.View>
</ViewCell>