Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
925
XamDataGrid custom type children not displayed correctly
posted

Hi,

In XamDataGrid I am not able to display child rows correctly. My goal is to define the field layout in code dynamically. The objects bound to the grid have a dynamic list of properties which is not known at compile time in production. So far I got the properties showing up. However, there is a fix column called Nodes which contains the child items always. In the sample application attached, the child row gets visible when the first row is expanded, but the fields are not as expected. Every child field should be exactly under the parent field. Maybe it is worth mentioning that the method xdg_AssigningFieldLayoutToItem is not called for the child row.

 Any help is appreciated. Also a simpler approach to use ICustomTypeDescriptor would be nice (currently I have to derive from Dictionary<string, string> which is not used by my implementation, because I forward the calls to TreeItemBase).

Sample code: XamDataGridCustomTypeChildrenNotDisplayedCorrectly.zip

Parents
No Data
Reply
  • 34430
    Verified Answer
    Offline posted

    Hello Tomas,

    I have been investigating into the sample project you have provided, and I am attaching a modified version of it. It appears the extra “Nodes” expandable record was showing up due to a mistake in the creation of the Fields where “field4” DataType was set to the ObservableCollection<MyCustomClass>, where it should have been “field5” as that is what was bound to the “Nodes” collection.

    I also found an interesting behavior that both .NET and therefore the XamDataGrid thinks that your base-level custom object is a collection type – hence the reason you need to bind to the “Items.<property_name>” property in the AlternateBinding. The child items, however are not being recognized as collection types, and so you can use the AlternateBinding directly to the property name.

    I am attaching a modified version of the sample project to demonstrate the fixed behavior. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    WpfApplication6.zip

Children
No Data