0
votes

I have a Button in a 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>

Two undesirable things are happening.

1) The bottom of the containing ViewCell is just beneath the button's text - it's as if the baseline of the text is aligned to the bottom of the cell.

2) If I click on the button, its click event doesn't fire and the whole cell flashes. Except if I click just above the text - in which case there is no flashing and the click event is raised.

How can I fix these issues? I'd prefer no flashing, correct alignment and proper hit testing.

enter image description here

2

2 Answers

0
votes

I don't know about your problem, but I suggest to:

  1. Add "ColumnDefinition" property to your Grid (Rows_and_Columns)
  2. Add Grid.Row and Grid.Column property to StackLayout control
  3. Remove Grid.Row property from Editor control (it's inside a StackLayout, so StackLayout should have Row and Column property)
  4. Add Grid.Column property to Button control
  5. Post images of your actual problems
  6. Do you have the problem on iOS, Android, UWP?
  7. A repo on GitHub could be useful
0
votes

I moved the margins to the child elements...

<?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>