BO之间共享财产? [英] Share Property between BOs?

查看:56
本文介绍了BO之间共享财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我在这里有点新意,希望我的问题不是很愚蠢。



我有一个BOTableRow,其属性Time和Value实现了INotifyPropertyChanged。然后我使用TableRows的Collection(实现INotifyCollectionChanged-Events)来填充一些DataGridViews,这些DataGridViews是用虚拟模式设置的,带有Data。



我的问题是:所有DataGridViews的Time值应该相同。另一个属性特定于它自己的DataGridView。因此,当我在一个视图中操作列时间的第1行时,所有视图都应使用新值更新其第一行。



现在我通过使用自实现类型ObservableDictionary< t>来解决这个问题。对于我的BO上的Value属性。因此,每个DataGridView都可以使用键查找它自己的Value值,但所有值都会查看Time的相同值。 (他们都被绑定到相同的BO列表。)



有没有更简单的方法来解决这个问题?干涉这些字典使得事情变得比我认为的要复杂得多。

Hey guys,

I am kinda new here, hope my question isn't plain stupid.

I have a BO "TableRow" with properties Time and Value implementing INotifyPropertyChanged. Then I use a Collection (which implements INotifyCollectionChanged-Events) of TableRows to fill some DataGridViews, which are setup with virtual mode, with Data.

My problem is: The value of Time should be the same for all DataGridViews. The other property is specific to it's own DataGridView. So when i manipulate Row 1 of Column "Time" in one view, all views should update their first row with the new value.

Right now I am solving this by using a self implemented type ObservableDictionary<t> for the Value property on my BO. So each DataGridView can look up it's own value of Value with a key, but all will look at the same value for Time. (They are all bound to the same List of BOs.)

Is there an easier way to solve this? Meddling around with those Dictionaries makes things more complicated than I feel they should be.

推荐答案

不是解决方案 - 但也许它会帮助你找到一个:



我设置了一个没有UI对象的测试框架 - 没有DataGridViews - 并在调试器中探索我需要做什么才能使数据表现我想要的方式。



一旦你的集合(和集合元素)正确地通知了变化,并根据需要响应变化,那么我才会开始将它传递到UI中(它往往有自己古怪的行为,可以混淆事情。)



HTH,

Chris
Not a solution - but maybe it'll help you get to one:

I'd set up a test framework without the UI objects - no DataGridViews - and explore in the debugger what I need to do to get the data to behave how I want it.

Once you've got your collections (and collection elements) properly notifying changes, and responding to changes as needed, only then would I start plumbing it into a UI (which often has its own quirky behaviours that can confuse things).

HTH,
Chris


这篇关于BO之间共享财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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