Hey Guys,
I'm using a XamDataGrid (v15.2) with a TemplateField but I'd like to dynamically create this field instead of defining it in my XAML FieldLayout.
My grid is being used by a variety of ViewModels / Models each with different fields for different use cases. I'm using the TemplateField to define a custom field editor but it's possible that this field won't be needed for a use case. As a result, I end up with two FieldLayouts - one that's dynamically created using the fields in my Model (AutoGenerateFields = true) and one with the TemplateField.
Thanks in advance for your help!
Any ideas??
Thank you for your response. I can't provide a sample app because of security reasons but below is a more descriptive explanation.
I have a common view that's shared by different viewmodels, each of which represents different use cases like creating or amending orders. My view has a xamdatagrid and the fields are autogenerated based on the models of the viewmodels. One of the fields in one of my models uses a template field defined in the field layout of my xamdatagrid via xaml. I use a template field because I am using a custom control my team created as an editor for the field.
Unfortunately, since the template field is in the xamdatagrid of my common view, that means that every use case will have that field layout defined. This isn't a problem if the field is needed by the use case but if it isn't, the grid will end up having two field layouts - the one that's autogenerated based on the model and one that's defined in the xaml.
I want to create a template field without explicitly defining it in my xaml in order to avoid the above issue. Putting it in code behind might work but I'm not finding a good example of how.
Hello Amilcar Javier,
Thank you for your post.
I have been looking into the description you have provided, but it seems like I am missing something from your scenario, so if this is still an issue for you, could you please provide me with more details about your views and models and the functionality that you are using? It will be great if you could share a simple sample project that illustrates your scenario. This way I would be able to further investigate this for you and provide you with more detailed information on this matter.
Also I can suggest you to take a look at the following links, where similar scenarios were discussed:
http://es.infragistics.com/community/blogs/blagunas/archive/2012/10/24/xamdatagrid-dynamically-create-and-data-bind-columns-with-an-editor-of-your-choice.aspx
http://stackoverflow.com/questions/3425972/mvvm-how-to-create-columns-at-runtime-for-a-xamdatagrid
Looking forward to hearing from you.