【问题标题】:How to avoid TableView scroll on XAML Forms?如何避免 XAML 表单上的 TableView 滚动?
【发布时间】:2017-08-31 22:16:49
【问题描述】:

我有一个 StackLayout,其中包含一个 TableView、一个网格和几个标签。

我的问题是 StackLayout 强制所有元素覆盖 100% 的屏幕高度,并且在我的 TableView 上生成垂直滚动:

我想删除控件内的垂直滚动,而是为整个视图设置一个“全局”滚动。

这是该视图的 XAML 代码:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="Create Account" 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:AudioBitts"
    x:Class="AudioBitts.SignUpPage">
    <StackLayout>
        <TableView x:Name="socialListView">
            <TableRoot>
                <TableSection Title="Social sign up">
                    <ImageCell ImageSource="{local:EmbeddedImage ResourceId=AudioBitts.Images.Icons.socialFacebook@3x.png}" Text="Sign up with Facebook" />
                    <ImageCell ImageSource="{local:EmbeddedImage ResourceId=AudioBitts.Images.Icons.socialTwitter@3x.png}" Text="Sign up with Twitter" />
                    <ImageCell ImageSource="{local:EmbeddedImage ResourceId=AudioBitts.Images.Icons.socialGoogle@3x.png}" Text="Sign up with Google+" />
                </TableSection>
                <TableSection Title="Email sign up">
                    <EntryCell Label="Email" Placeholder="Your email"/>
                    <EntryCell Label="Password" Placeholder="Min 6 characters"/>
                </TableSection>
            </TableRoot>
        </TableView>
        <Grid Padding="20" HorizontalOptions="Center" VerticalOptions="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Text="Already have an account?" />
            <Label x:Name="onSignIn" Grid.Row="0" Grid.Column="1" Text="Sign In" TextColor="#ff0030" />
        </Grid>
        <Label Text="AudioBitts Inc." HorizontalOptions="Center" /> 
        <Label Text="Terms of Use and Privacy Policy" HorizontalOptions="Center" />
    </StackLayout>
</ContentPage>

【问题讨论】:

  • 首先为您的桌子指定高度
  • 所以如果我添加一个新的社交网络选项,我需要更新那个高度吗?有没有更动态的方式?

标签: xaml user-interface xamarin.forms tableview


【解决方案1】:

为什么不添加另一个&lt;TableSection/&gt;,添加一个&lt;ViewCell/&gt;,然后添加Grid 中的内容。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-06
    • 2018-02-25
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 2018-09-27
    • 2017-03-31
    • 1970-01-01
    相关资源
    最近更新 更多