移除 Xamarin.Forms 中 ListView 视图单元格的分隔符

6

我的项目中使用了Xamarin.Forms的ListView,我使用ViewCells来显示数据。

目前,在两个ViewCells之间会显示一条分隔线。有没有办法去掉这个分隔线,让两个ViewCells始终相连?

我尝试使用SeperatorVisibility="None",但没有任何变化。

以下是我的代码:

 <ListView x:Name="AList"
                StyleId="AList"
                      Grid.Row="0"
                RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"
                      IsVisible="{Binding IsProcessing, Mode=OneWay, Converter={StaticResource booleanNegationConverter}}"
                SeparatorVisibility="None">
        <ListView.BackgroundColor>
          <OnPlatform x:TypeArguments="Color" iOS="Transparent" />
        </ListView.BackgroundColor>

        <ListView.RowHeight>
          <OnPlatform x:TypeArguments="x:Int32" iOS="150" Android="150" WinPhone="170" />
        </ListView.RowHeight>
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell > .......</ViewCell></ListView>

你也可以为ListView编写自己的CustomRenderer,例如SeperatorlessListView。 对于iOS,你可以参考这个链接:https://forums.xamarin.com/discussion/comment/74497/ 祝好运 :) - Patrick Jelitto
4个回答

14

SeperatorVisibility="None" 通常对我来说就可以了。

您是否在所有平台上都看到了这个问题?

您的视图单元格中是否包含可能导致此问题的任何内容?尝试切换到标准的 TextCell,看看您是否获得了分隔符。


我也遇到了SeperatorVisibility不起作用的问题。在多次重新构建项目后,它最终删除了行分隔符,这只是给那些苦苦挣扎的人一个提示。可能是个bug吗? - FrankCastle616
你的正确答案中有一个拼写错误:应该是 SeparatorVisibility="None"。 - innom

2
使用SeparatorColor属性在ListView中。
<ListView SeparatorColor="Transparent">
</ListView>

0

添加

Footer=""

将此代码添加到您的 ListView XAML 标记中。

0

Xamarin 4.6.0.847,属性:SeparatorVisibility

<StackLayout VerticalOptions="FillAndExpand" BackgroundColor="White">
    <ListView x:Name="ListViewMenu"
              HasUnevenRows="False"
              SeparatorVisibility="None">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout>
                        <Grid Padding="10" BackgroundColor="White">
                            <Label Text="{Binding Title}" FontSize="20"/>
                        </Grid>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接