Separator in ListView (WPF)?

谁说我不能喝 提交于 2019-12-01 04:10:58

问题


I'm gonna insert a Separator in a ListView in WPF , something like this :
image

I've used the following XAML code, but it dosn't work !

<ListView ItemsSource="{Binding ListViewItemsCollections}">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Name" Width="200" DisplayMemberBinding="{Binding GridViewColumnName}"/>
            <GridViewColumn Header="Tags" Width="200" DisplayMemberBinding="{Binding GridViewColumnTags}"/>
            <GridViewColumn Header="Location" Width="400" DisplayMemberBinding="{Binding GridViewColumnLication}"/>
        </GridView>
    </ListView.View>
    <Separator />
</ListView>

Could you please guide me ? Thanks.


回答1:


Mohammad,

I believe inserting a separator (or a control which mimics one) is far more simple than you think :)

First of all, please take a look on how DataTemplate should be applied to a ListBox/ListView. You can find it here. Secondly, you have to decide how you're going to mimic a Separator. You can find 2 excellent examples here and here. Please keep me informed if your task is done :)




回答2:


Try putting the separator in the collection of items you are binding to. In the above code you are stting the items via the itemsSource binding and then setting the items by adding a seperator to the content. Add the seperator to the collection of items and you will see a blank row in your grid. you might have to style the separator accordingly. (but it will give you a row you cant click on)



来源:https://stackoverflow.com/questions/2056507/separator-in-listview-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!