自定义ListView以具有不同的数据视图 [英] Customizing ListView to have different data view

查看:66
本文介绍了自定义ListView以具有不同的数据视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试创建具有类似ListView-GridView的列数的控件.但是我需要在任一列中显示数据.

说我有一个4列的ListView.我有一个数据对象,它可以在运行时显示在4列中的任何一列中,而不是所有列中一样

我该如何实现?我已经开始自定义ListView的样式,但没有帮助.我正在尝试创建一个像甘特图这样的控件.我知道市场和codeplex中都有控件,但是我需要自己做,因为它要求对我的业务进行更多的自定义.

在Advance中致谢

Hi All,

I am trying to create a control with number of columns like ListView-GridView. But I need to display data in any of the one columns.

Say I have a ListView of 4 columns. I have a data object which can be displayed in the any of the 4 columns at runtime not like all the columns

How can I achieve it? I started have already customized the style of the ListView but not helping. I am trying to create a control like Gantt Chart. I know there are controls in market and codeplex but I need to do this myself as it request more customization toward my business.

Thanks in Advance

推荐答案

一种方法可能是构建基础集合(将列表视图绑定到的基础集合),然后将数据对象放入其中.您希望它位于的任何列/位置.

在这种情况下,您的列表视图不必担心需要在何处显示什么,它只需要进行绑定即可.建立集合的方式变得很重要.
One way could be to build your underlying collection (the one you bind your listview to) in such a way that the data object can then be in whatever column / position you want it to be in.

In this case, your listview need not worry about what needs to be displayed where, it just does the binding. The way you build your collection becomes important.


我找到了解决方案.我需要自定义ListViewItem的样式,在其中可以将GridViewRowPresenter替换为ContentPresenter或可以帮助以colspan类型显示行的内容.
I have found the solution. I need to customize the Style of ListViewItem where I can replace the GridViewRowPresenter to ContentPresenter or something which would help to show the row in colspan type.


这篇关于自定义ListView以具有不同的数据视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆