动态GridView [英] Dynamic GridView

查看:63
本文介绍了动态GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GridView创建类似财务报告的内容。这些列是报告期间,直到运行时才会知道。

I want to use a GridView to create something like a financial report. The columns are reporting periods and are not known until run time.

                                               
jan                      二月                   
mar            4月

                                              jan                        feb                    mar            april

应收帐款              10                         30                     
90               11

Accounts Receivable              10                         30                      90               11

广告资源                                432                     
23                     34                12

Inventory                               432                      23                      34                12

绑定元素具有一系列与各列相关的值。为了得到一个值,我需要一个元素(库存)和一个报告周期(2018年1月)。

The binding element has a collection of values that pertain to various columns. In order to derive a value, I need both an element (inventory) and a reporting period (Jan-2018).

该元素具有基于报告周期的值集合。但我无法绑定到集合以获取元素/句点组合的正确值。

The element has a collection of values based on reporting period. But I cannot bind to the collection to get the correct value for an element/period combination.

根据定义,绑定引用元素的属性。在这种情况下情况并非如此。我需要在元素包含的可观察集合中引用特定对象。

By definition, bindings reference properties of the element. That is not the case in this instance. I need to reference specific objects in an observable collection contained by the element.

我可以动态创建列。我将报告期间对象放在列的Tag属性中。问题是:如何将网格单元格绑定到元素和报告周期以显示正确的值。

I can create the columns dynamically. I put the Reporting Period object in a Tag attribute of the column. The question is: how do I bind the grid cells to both the element and the reporting period in order to display the proper value.

推荐答案

看看这里引用的示例:

Take a look at the sample referenced here:

https://social.technet.microsoft.com/wiki/contents/articles/28797.wpf-dynamic-xaml.aspx#Awkward_Bindings_Data

https://social.technet.microsoft.com/wiki/contents/articles/28797.wpf-dynamic-xaml.aspx#Awkward_Bindings_Data

听起来你想要一些非常相似的东西。

Sounds like you want something very similar.


这篇关于动态GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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