Share via


ListView Separator Style on iOS

This iOS platform-specific controls whether the separator between cells in a ListView uses the full width of the ListView. It's consumed in XAML by setting the ListView.SeparatorStyle attached property to a value of the SeparatorStyle enumeration:

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
    <StackLayout Margin="20">
        <ListView ... ios:ListView.SeparatorStyle="FullWidth">
            ...
        </ListView>
    </StackLayout>
</ContentPage>

Alternatively, it can be consumed from C# using the fluent API:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

listView.On<iOS>().SetSeparatorStyle(SeparatorStyle.FullWidth);

The ListView.On<iOS> method specifies that this platform-specific will only run on iOS. The ListView.SetSeparatorStyle method, in the Xamarin.Forms.PlatformConfiguration.iOSSpecific namespace, is used to control whether the separator between cells in the ListView uses the full width of the ListView, with the SeparatorStyle enumeration providing two possible values:

  • Default – indicates the default iOS separator behavior. This is the default behavior in Xamarin.Forms.
  • FullWidth – indicates that separators will be drawn from one edge of the ListView to the other.

The result is that a specified SeparatorStyle value is applied to the ListView, which controls the width of the separator between cells:

ListView SeparatorStyle Platform-Specific

Note

Once the separator style has been set to FullWidth, it cannot be changed back to Default at runtime.