首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带分隔线的ListView ItemTemplate

带分隔线的ListView ItemTemplate
EN

Stack Overflow用户
提问于 2022-03-18 09:01:45
回答 1查看 82关注 0票数 0

这段来自wpf-tutorial.com的代码

代码语言:javascript
运行
复制
<Window x:Class="WpfTutorialSamples.ListView_control.ListViewItemTemplateSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ListViewItemTemplateSample" Height="150" Width="350">
    <Grid>
        <ListView Margin="10" Name="lvDataBinding">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <WrapPanel>
                        <TextBlock Text="Name: " />
                        <TextBlock Text="{Binding Name}" FontWeight="Bold" />
                        <TextBlock Text=", " />
                        <TextBlock Text="Age: " />
                        <TextBlock Text="{Binding Age}" FontWeight="Bold" />
                        <TextBlock Text=" (" />
                        <TextBlock Text="{Binding Mail}" TextDecorations="Underline" Foreground="Blue" Cursor="Hand" />
                        <TextBlock Text=")" />
                    </WrapPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Window>

如果用一条分隔元素的线,我如何才能达到同样的结果呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-18 09:17:06

您可以使用项目容器样式在每个容器的底部绘制边框。

代码语言:javascript
运行
复制
<ListView.ItemContainerStyle>
   <Style TargetType="{x:Type ListViewItem}">
      <Setter Property="BorderThickness" Value="0,0,0,2"/>
      <Setter Property="BorderBrush" Value="Red"/>
   </Style>
</ListView.ItemContainerStyle>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71524590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档