My case is like this:
I have a List
public List<string> CategoryList{ get; set; }
In xmal, I bind like this
DataSource="{Binding CategoryList, Mode=OneWay}"
1. I don't know how to write the TextField label.
2. After I set this list to a list of string, the grid shows the row numbers but no data.
How can I display this list of string in the xamDataGrid?
Hello,
I have been looking into your question, however, by default the approach with defining Fields, TextFields, etc. and set their name property works if the field corresponds to a specific property of the underlying data.In your scenario instead of defining field layout, I can suggest two approaches:
1. Set the AutoGenerateFields property to true and in the grid's FieldLayoutInitialized event handler gets the field and set its Label per your requirement:
private void XamDataGrid_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e) { e.FieldLayout.Fields["Value"].Label = "My Label"; }
2. Instead of TextField define it as UndoundField:
<igDP:XamDataGrid DataSource="{Binding Mode=OneWay}"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:UnboundField BindingPath="." Name="Value" Label="My Label"/> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
I have attached a sample application, that uses the second approach, however, as a comment, you could find the first as well. Please test it on your side and let me know if I may be of any further assistance.
Sincerely,Teodosia HristodorovaAssociate Software Developer
7356.XDG_to_List.zip