简体   繁体   English

在一个包含带有列标题的GridView的视图和另一个不包含列标题的视图之间动态更改WPF ListView

[英]Dynamically changing a WPF ListView between one that contains a GridView with column headers and another view that doesn't

I'm not quite sure how to go about this so any advice would be much appreciated. 我不太确定该怎么做,因此任何建议都将不胜感激。

I have a ListView whose default implementation is using with column headers. 我有一个ListView,其默认实现与列标题一起使用。 At runtime in the program I would like to be able to click on a button at runtime to change the view so that the list view loses the GridViewColumn headers and implements a new style using one of my own data template. 在程序的运行时,我希望能够在运行时单击按钮来更改视图,以使列表视图丢失GridViewColumn标头,并使用自己的数据模板之一实现新样式。

Then I would also like the ability to click the button and change the ListView back to a grid view with column headers. 然后,我还希望能够单击按钮并将ListView更改回带有列标题的网格视图。

Can anyone point me in the correct direction of how to go about this? 谁能指出我正确的方向?

Thanks 谢谢

由于ListView.View是依赖项属性,因此可以通过转换器将其绑定到VM上的某些内容。

Microsoft has a sample that demonstrate how to create a ListView control that displays data in multiple view modes, which include the GridView and other custom view modes. Microsoft有一个示例,该示例演示如何创建一个ListView控件,该控件以多种视图模式显示数据,包括GridView和其他自定义视图模式。

Search for ListView with Multiple Views Sample in the WPF Documentation Sample page. WPF文档示例页面中搜索具有多个视图示例的ListView http://archive.msdn.microsoft.com/wpfsamples http://archive.msdn.microsoft.com/wpfsamples

Here is a direct link to download the sample: http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7766 这是下载示例的直接链接: http : //archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples& DownloadId= 7766

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM