开发者

WPF MvvM DataGrid variable Columns through a IList of columns

I am searching about how to create variable number of columns in a DataGrid from the Ilist in MVVM way. The requirement I am working on is very big and also the number of rows and columns are not known But I did n开发者_运维技巧ot find satisfactory answers

Is there some one that had to do the samething ?

If there is no way of generating such columns, I know I can do that by binding DataGrid to a DataSet. Then I have one more problem; if I am using DataSet, how do I display different UI in different cells based on some parameter?

Please help its very urgent requirement!!!!!!!!


Ok, I haven't tried this myself, but I think you should be able to pull this off by creating a dynamic object, and binding to a list of MyDynamicObject. WPF supports binding to dynamic objects (MSDN). Theoretically it could work like this:

public List<dynamic> MyDynamicList {get; set;}

dynamic obj = new MyDynamicObject();
obj.DisplayCode = "Test";
obj.SomeProperty = "hello world";
MyDynamicList.Add(obj);

You will need to create MyDynamicObject by implementing IDynamicMetaObjectProviderand DynamicMetaObject. More on this here.

Hope this will put you in the right direction...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜