I have 1 datasource and the user wants to see 2 different views in a grid. I was hoping to create a style that I could apply to the datagrid that would define different columns from the same datasource and change the style in my ViewModel based on a checkbox or something. Is there a way to define a style for a datagrid that will define the FieldLayout.Fields and SortedFields and allow me to Bind from my datasource so that I can switch layout on the fly?
Hello Adam,
I am glad that this example was helpful for you. AssigningFieldLayoutToItem event fires when an item from the data source is associated with a FieldLayout and the best approach I could currently think of for calling this method is re-binding the source. I will update this thread with additional information if I come up with a better solution.
Thank you. The example was helpful and I was able to switch out the FieldLayouts on the fly in my code behind but I really was trying to figure out how to trigger the event from my View or Entity Model so I don't need to have that dependency to my code behind. If you have any ideas on how I might be able to trigger the AssigningFieldLayoutToItem event handler in my View or Entity model using Attached or Dependency Properties that would be most helpful.
Adam
Hi Adam,
I am just checking if my last reply was helpful for you.
If you require any further assistance, please do not hesitate to ask.
Hello Adam and thank you for posting!
FieldLayouts are automatically generated when the XamDataGrid control is bound to data source and AutoGenerateFields property is set to true. You may create the FieldLayouts and then add a custom logic to the AssigningFieldLayoutToItem event to choose which one to be used. This event fires when the data source is bound to the grid so in order to call it again you should rebind the grid. In this forum thread there is additional information on the matter: http://ko.infragistics.com/community/forums/p/41460/231170.aspx.
I have attached a sample project that uses the same approach to demonstrate it. If you have any questions, let me know.