Hi guys,
have a question regarding Field's binding.
I've got a model similar to this one:
public class Person
{ public string Id { get; set; }
public string Name { get; set; }
public List<Orders> Orders { get; set; }
}
public class Order{
public string Id { get; set; }
public class ViewModel
{
public ObservableCollection<Person> { get; set; }
I''m binding List<Person> to XamTreeGrid and displaying data using XAML like:
<igDP:XamTreeGrid.FieldLayouts> <igDP:FieldLayout Key="Person" IsDefault="True"> <igDP:Field Name="Orders" Label="Orders:" /> <igDP:TextField Name="Id" Label="Id" /><igDP:TextField Name="Name" Label="Name" /> </igDP:FieldLayout> <igDP:FieldLayout Key="Order" IsDefault="False"><igDP:TextField Name="id" Label="Id" /><igDP:TextField Name="Name" Label="Name" /> </igDP:FieldLayout> </igDP:XamTreeGrid.FieldLayouts>
All looks good.
The problem comes when I need to introduce one more layer (my architecture needs that) and the code looks like:
public class Wrapper<T>
public T Data { get; set; }
public ObservableCollection<Wrapper<Person>> { get; set; }
Hello,
I am just checking if you require any further assistance on the matter.
Hello Darisuz,
Thank you for your feedback.
I have been investigating your issue. In order to be able to achieve your requirements you should define both FieldLayouts – for Person and for Order collections, also you should assigned Keys for Person and Order and set the ParetFieldLayoutKey of the Order to “Person” , so you will eliminate confusion when assign a field layout to item. In Person FieldLayout you can use AlternateBinding in order to be able to access your inner collection by Data property from you wrapper class. Finally you should handle FieldLayoutIntializing event in order to set the DataType of the Parent.Orders field to IEnumerable type. You can read more details about AlternateBinding from the following link:
http://help.infragistics.com/doc/WPF/2015.1/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v15.1~Infragistics.Windows.DataPresenter.Field~AlternateBinding.html
I modified the sample application to show you how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Hi,
In your sample app you implemented the first bit, the one that actually works.
The problem is the second bit - when I introduce Wrapper<T>
thanks
Hello Dariusz,
Thank you for your post.
I have been looking into it. I am not sure that understand your issue and scenario correctly, would you please provide me with more details about them. I created short sample application based on your scenario, it will be great if you could modify it with the functionality that you are using, so I will be able to investigate you issue.
Looking forward to hearing from you.