WPF XAML Listview水平线

WPF XAML Listview水平线,wpf,xaml,listview,Wpf,Xaml,Listview,我想在每个项目之间的listview中添加一条水平线(见图) 我不确定如何调整我当前的xaml来实现这一点。如果可能的话,我希望线条在图片的两端淡出 谢谢 当前XAML: <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Foreground" Value="#787f82"

我想在每个项目之间的listview中添加一条水平线(见图)

我不确定如何调整我当前的xaml来实现这一点。如果可能的话,我希望线条在图片的两端淡出

谢谢

当前XAML:

<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="#787f82" />
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListViewItem}">
            <Border
                 BorderBrush="Transparent"
                 BorderThickness="0"
                 Background="{TemplateBinding Background}">
                <GridViewRowPresenter HorizontalAlignment="Stretch" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
            </Border>
        </ControlTemplate>
    </Setter.Value>
</Setter>

示例图片:

我自己能解决这个问题。我将在下面发布我的代码,这样其他人可能有机会自己做

我只需为每个项目的底部设置一个边框,然后将渐变应用于边框

 <Style x:Key="level1" TargetType="{x:Type ListViewItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="#787f82" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Border
                         BorderThickness="0,0,0,2"
                         Background="{TemplateBinding Background}">
                        <GridViewRowPresenter HorizontalAlignment="Stretch" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
                        <Border.BorderBrush>
                            <LinearGradientBrush StartPoint="0,1" EndPoint="1,0" Opacity="0.3">
                                <GradientStop Offset="0" Color="transparent"/>
                                <GradientStop Offset="0.5" Color="white"/>
                                <GradientStop Offset="1" Color="transparent"/>
                            </LinearGradientBrush>
                        </Border.BorderBrush>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background">
                    <Setter.Value>
                        <ImageBrush ImageSource="images/selection-large.png"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderThickness" Value="0" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background">
                    <Setter.Value>
                        <ImageBrush ImageSource="images/selection-large.png"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Foreground" Value="#FFFFFF" />
                <Setter Property="FontWeight" Value="bold" />
            </Trigger>
        </Style.Triggers>
    </Style>

我的解决方案是使用
ListView.ItemContainerStyle
属性设置我想要的项目容器样式

                <ListView ItemsSource="{Binding Champs}" Name="listView1" HorizontalContentAlignment="Stretch" Background="Transparent" Padding="-1" >
                    <ListView.ItemContainerStyle>
                        <Style>
                            <Setter Property="Control.Background" Value="White" />
                            <Setter Property="Control.BorderThickness" Value="0.3" />
                            <Setter Property="Control.BorderBrush" Value="Black" />
                        </Style>
                    </ListView.ItemContainerStyle>

                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0,5,0,5">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding Nom}" FontWeight="Bold" FontSize="10" />
                                <TextBox Grid.Row="1" TextAlignment="Center" Text="{Binding Valeur}" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListView>


u是否可以为Listview发布完整的xaml,因为绑定它时它不会显示任何内容。如果没有这一点,它的工作原理就像在ListView中不显示任何内容一样,ListView XAML中显然遗漏了一些内容,但仍然没有显示