Hi,
is there any way to assign a FieldLayout instance (stored as a resource) to 2 XamDataGrid?The problem is the following. I have a XamTabControl and I want to load a XamDataGrid into each TabItem but with the same FieldLayout settings.As my first step I created a FieldLayout resource and set up the FieldLayout property. That's ok. But at the second TabItem there is an error:"Field can not be moved to another collection."Is there any way to clone or copy (or something else) this class? One of the points is that we can't know how many TabItems will be exactly, sosetting up 2 FieldLayout resource would not be a right solution.Should I create a special collection with the fields' descriptions and create them from code inside for example a foreach statement?
Thank you for your replies in advance.
Regards,atus
Hello,
how set Shared property to resource in code?
xamDataGrid.Resources.Add("FieldLayoutOsoby", myFieldLayout);
Thanks.
Hi
I want also to use the same FieldLayout in a different grid. However i don't have access to the resouce only to the other grid. How can i copy it's FieldLayout?
Also in terms of copying / cloning, how can i copy / clone a Field?
This property is not shown by the IntelliSense of the Visual Studio, but every resource should have that.
The problem I am having at this point is that I do not have a "x:Shared" option in a resource dictionary. The resource dictionary is where I am placing my field layouts.
Hello Atus,
You can do this by creating a field layout as a resource and then adding that FieldLayout in the FieldLayouts collection of the XamDataGrid. However, you cannot move it - fieldlayout from one grid to another. So, for example, I have defined my layout as this:
<igDP:FieldLayout x:Key="FieldLayout" x:Shared="false">
<igDP:FieldLayout.Fields>
<igDP:Field Name="name" />
<igDP:Field Name="department" />
<igDP:Field Name="salary" />
<igDP:Field Name="email" Visibility="Hidden"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
Please note that you must set the x:shared property to false, because you will get an exception. Setting this to false, a new instance of that resource will be created when it is requested. After that in code, I apply this FieldLayout to my XamDataGrid and bind them:
xamDataGrid1.FieldLayouts.Add(MainWindow.Resources["FieldLayout"] as FieldLayout);
xamDataGrid2.FieldLayouts.Add(MainWindow.Resources["FieldLayout"] as FieldLayout);
xamDataGrid1.BindToSampleData = true;
xamDataGrid2.BindToSampleData = true;
Please let me know if you have questions on this.