You could use the following code to add custom separators in the ListView.
The code of xaml:
<Window.Resources>
<Style x:Key="MySeparatorStyle" TargetType="{x:Type Separator}">
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border Width="80"
BorderBrush="Black"
BorderThickness="1"
Background="LightGray"
Height="30"
SnapsToDevicePixels="true">
<TextBlock Background="AliceBlue" Width="80" Height="30" Text=" separator "/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="myCellTemplateName">
<StackPanel>
<TextBlock Background="LightGray" Width="80" HorizontalAlignment="Center" Text="{Binding Name}"/>
<TextBlock Background="LightGreen" Width="80" Text="separator"/>
<Separator Style="{StaticResource MySeparatorStyle}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="myCellTemplateEmployeeNumber">
<StackPanel>
<TextBlock Background="LightGray" Width="80" HorizontalAlignment="Center" Text="{Binding EmployeeNumber}"/>
<TextBlock Background="LightGreen" Width="80" Text="separator"/>
<Separator Style="{StaticResource MySeparatorStyle}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<ListView Name="lv" ItemsSource="{Binding}" BorderThickness="0">
<ListView.View>
<GridView>
<GridViewColumn CellTemplate="{StaticResource myCellTemplateName}" Header="Name" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource myCellTemplateEmployeeNumber}" Header="Employee No." Width="100"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
The picture of result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.