English 中文(简体)
能否成为WPF数据网中项目来源的代理?
原标题:Making a proxy for ItemSource in a WPF Datagrid, is this possible?

在目前开展的Im项目中,我没有平原航天中心对我的数据网进行约束。 通常,我将使用一种可观察的Collection<MyObject>,但现在我可以而且相反,我必须使用一种习俗物体(如可数据但符合习惯逻辑)。

My question is : How can I make a proxy/adapter object that will "translate" every binding operations on items in cells of my datagrid to my custom logic object?

牢记:

  • My object is not a Collection, so I don t really have Items.
  • The "columns" of the virtual items might change.
  • Somewhere in the application I might change one value in that object and that the datagrid must reflect changes

现在,我们正在重新研究从习俗物体中提取数据,以在数据网中显示其数据意见,我们拦截带有事件的编辑指令(即刻),然后在改变电池价值时从零头重载一切。

我在寻找如何实现这一目标的方面,但我发现的情况是:

  • IItemProperties interface (Might be interesting to have dynamic columns but I don t have a collection)
  • DataSourceProvider class (It appears to be a wrapper for ItemsSource, but I don t see what I have to return in the Data property)
  • INotifyPropertyChanged interface (To tell a property changed, but I don t have items or at least items don t have properties)
  • ICustomTypeDescriptor interface (Ok but once I returned the properties with GetProperties() how the datagrid will try to modify the inexistent property?)

你可以看到,它混淆了选择一种执行好代理的方法。

最佳回答

最后,我找到了解决办法。 我也把ICustomTypeDescriptor在每座摇篮上使用,并称主机反对。

问题回答

I would suggest creating kind of a ViewModel as an adapter between your Model (that mysterious object that is no collection but is viewed as one) and your View (the DataGrid). You will find various examples for this pattern when searching for Model-View-ViewModel. Then you can define properties yourself, you only need to implement some suitable get/set-methods on your properties, to transfer ViewModel-changes to your original Model and vice versa (if needed).

页: 1 你可以轻而易举地从动态目标(只有4.0)中继承,其动态特性将受到Xaml的约束。 代表您的数据 替换的 在其代理人上执行<条码>。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签