Hello,
recently I am trying to replace some simple XamGrid tables to to XamDataGrid and this seem to get complicated very easily.
for example:
with XamGrid I have 2 TemplateColumns bound to different properties of my viewmodel (It is working properly). What I like about it is that I can define the HeaderText. This seems not to be possible with XamDataGrid:
<igDP:XamDataGrid x:Name="xamDataGrid" DataSource="{Binding MyProperty}" GroupByAreaLocation="None"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="MyProperty" Label="Header Text" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
This is not working at all. I'm not even able to type anything.
However, if I set AutoGenerateFields="True", I am able to see the header "Value" (and I desperately want to chande the header). Most importantly, I am not able to type anything IF MyProperty is "empty", i.e. it has a default value of 0. I can only type something in when it is not empty. So for example if MyProperty was set to be 5, I can see the number and can change it. It also binds properly whenever I type in a different number. Why is that ?Thank you.
Kind regards,
Julian
Hello Julian,
I have been investigating into the behavior you are looking to achieve, and I am curious to know what your data source is in this case? Are you binding to a collection of your own type where “MyProperty” is a property on that type, or are you binding to something like a List<string> in this case? Also, what type is “MyProperty” in this case?
The information above will help me to potentially answer why when it is empty, you cannot modify it, but if I had to guess it very likely has something to do with the resolution of the editor within the cells. From the code snippet you have provided, you are also correct to be changing the Label property of your Field in order to change the header text.
It is also worth noting that there is a TemplateField within the XamDataGrid’s API and you can read about its usage here: https://www.infragistics.com/help/wpf/xamdatagrid-configuring-template-field.
Please let me know if you have any other questions or concerns on this matter.
Hello Andrew,
MyProper is an ObservableCollection of my own type:
basically like so:
ObservableCollection<MyOwnType> MyProperty.
Where MyOwnType is a class having only a single double field.
Thank you for the provided link. I'm afraid that it won't work either since I'm having trouble in this simple case but I will give it a try when I have time.
Thank you for describing your data model in this case.
I am attaching a sample project to demonstrate the XamDataGrid working with a TemplateField in the context of what you have described.
XDGTemplateColumnDemo.zip