Alan2
Alan2

Reputation: 24592

How can I add a content area with text to the bottom of a TableView?

I have this code:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:local="clr-namespace:Japanese;assembly=Japanese" 
    xmlns:template="clr-namespace:Japanese.Templates"
    x:Class="Japanese.ATIPage"
    Title="Answer Visible">
    <ContentPage.Content>
        <TableView Intent="Settings" HasUnevenRows="false" RowHeight="50" x:Name="atiSection">
            <TableView.Root>
                <TableSection>
                    <template:ClickViewCellTemplate Text="{Binding [6].Name}" 
                        IsVisible="{Binding [6].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                    <template:ClickViewCellTemplate Text="{Binding [7].Name}" 
                        IsVisible="{Binding [7].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                    <template:ClickViewCellTemplate Text="{Binding [8].Name}" 
                        IsVisible="{Binding [8].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                </TableSection>
            </TableView.Root>
        </TableView>
    </ContentPage.Content>
</ContentPage>

What I would really like to do is to add some text message to a footer but from what I understand TableView does not have a footer.

Can anyone suggest how I could add a message into the area below the tableView. I know how to do the binding but not sure how if there is a XAML element that I can use for the text entry.

Upvotes: 0

Views: 79

Answers (1)

Bruno Caceiro
Bruno Caceiro

Reputation: 7199

If your text is not a part of the tableView, you can simple add it after the TableView. For example:

<ContentPage.Content>
<StackLayout Spacing="10">
        <TableView Intent="Settings" HasUnevenRows="false" RowHeight="50" x:Name="atiSection">
            <TableView.Root>
                <TableSection>
                    <template:ClickViewCellTemplate Text="{Binding [6].Name}" 
                        IsVisible="{Binding [6].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                    <template:ClickViewCellTemplate Text="{Binding [7].Name}" 
                        IsVisible="{Binding [7].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                    <template:ClickViewCellTemplate Text="{Binding [8].Name}" 
                        IsVisible="{Binding [8].IsSelected}" 
                        ClickAction="Handle_ClickAction" />
                </TableSection>
            </TableView.Root>
        </TableView>
<Label Text="YourTextHere" HorizontalOptions="Center" VerticalOptions="Center"/>
</StackLayout>

Now, it is a question of position the Label/elements where you want, to achieve that, you manipulate the VerticalOptions and HorizontalOptions of the Label property, or the Spacing in the StackLayout.

Upvotes: 1

Related Questions