可编辑的表有两个项目来源 [英] Editable table with two items sources

查看:55
本文介绍了可编辑的表有两个项目来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我是一直在使用MVVM模式开发WPF应用程序。对于一个特定的步骤,我需要一个表(绿色矩形) 看起来像在图片上。前两列(红色矩形) 来自一个SQL查询,thoe是一个itemsouce。蓝色的一个,应该是
动态生成,因为在1-999范围内可以有列,这取决于其他一些东西。因此,在生成表格之后,我需要为
E43964666等提供 
1 我该怎么办? ?我正在考虑使用CompositeCoolection和2个DataTemplates,一个用于源代码收集,但不知道哪个控件用于它。 ItemsControl或ListBox(查看)还是其他什么?我不需要解决方案,我需要一个
的帮助,一个提示。提前致谢。



Ladislav

解决方案

嗨Ladislav,


根据你的描述,你想在itemcontrol或ListBox(ListView)中显示一些数据,但这些数据来自两个table,所以你有一些关于绑定的问题。


如果Listview中的列不包含像combobox这样的控件,只需要一个简单的列来显示数据,就不能使用两个数据源了列表视图,我建议
你可以 创建一个"加入"的类。如果要从单个数据网格内部访问成员,请将这些数据元素放入单个实例中。或者你也可以看一下
以下帖子:


https://stackoverflow.com/questions/5412797/how-to-bind-a-listview-to-multiple- collections-stored-in-a-view-modemodel-in-w


最好的问候,


Cherry


Hi,

I've been developing WPF application using MVVM pattern. For one particular step i need a table(green rectangle) which looks like on the picture.First two columns(red rectangle) are from one SQL query,thoe are one itemsouce. Blue one, should be dynamically generated, becauce there can be columns in range 1-999, it depends on some other stuff. So after table is generated i need to put 1 for E43964666 etc. How should I do that? I'm thinking about using CompositeCoolection and 2 DataTemplates,one for source colection, but don't know which control use for it. ItemsControl or ListBox(View) or something else? I don't need a solution, I need a help, a hint. Thanks in advance for anything.

Ladislav

解决方案

Hi Ladislav,

According to your description, you want to display some data in itemcontrol or ListBox(ListView), but these data come from two table, so you have some issue about binding.

If the column in Listview does not contain a control like combobox, just a simple column to display data, you could not use two data source in Listview, I suggest you can make a class that "joins" these data elements into a single instance if you want to access members from both inside of a single data grid. or you can also take a look the following thread:

https://stackoverflow.com/questions/5412797/how-to-bind-a-listview-to-multiple-collections-stored-in-a-single-viewmodel-in-w

Best Regards,

Cherry


这篇关于可编辑的表有两个项目来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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