Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
460
Xamcombofield in Xamdatagrid is empty
posted

Please help there is no data in the drop down in the combobox field in the xamdatagrid this only thing it show that it is a collection

I have this class
````
public class AvisTIlGrid {
public int BureaoOrdreNr { get; set; }
public decimal Total { get; set; }
public int UgeavisID { get; set; }
public string bureauOrdreNr { get; set; }

public List<Fejl> fejl { get; set; }

}
````
````
public class Fejl
{
private string fejltekst;

public string FejlTekst { get => fejltekst; set => fejltekst = value; }
}
````
And in a Dao Class the fejl is populated with data from the FejlTekstTable

```
fejl = diMPdot.tblFejlTeksts.Select( f => new Fejl()
{
FejlTekst = f.FejlTekst
}).ToList()

````
The result from the query looks like this its a List<Fejl>
Ingen valgt
Bestilt for sent - ikke bragt
Ordre ikke modtaget
Glemt annonce
DLU har fremsendt forkert matr.
Vi har indrykket forkert matr.
Forkert farve
Forkert placering
Forkert annonce format
Glemt farve
````
````

And in my view class I have a XamDataGrid where Specify a ComboBoxField but when I run the code there is no data in the dropdown memu

````
<igWPF:ComboBoxField Name="fejl" DisplayMemberPath="FejlTekst" Label="Fejl" >
</igWPF:ComboBoxField>

The rest of the values is showing find in the textfields in the xamdatagrid

  • 2640
    Verified Answer
    Offline posted

    Hello Thomas,

    I have been looking into your question and created a small sample with a XamDataGrid and a ComboBoxField containing a list of objects as per your class structure.

    Since the property List<Fejl> fejl is a member of the AvisTIlGrid data model, every AvisTIlGrid object instance is associated with its own List<Fejl> fejl property. Therefore, the ComboBoxField’s ItemsSource should be set to the corresponding DataItem’s fejl property. This can be achieved by defining an EditorStyle targeting the XamComboEditor and adding a Setter for the ItemsSource. The DataContext of the XamComboEditor in the Cell is the DataRecord and the ItemsSource can be bound to its DataItem:

    <igWPF:ComboBoxField Name="fejl" Label="Fejl" DisplayMemberPath="FejlTekst" ValuePath="FejlTekst" BindingType="Unbound">
                                <igWPF:ComboBoxField.Settings>
                                    <igWPF:FieldSettings>
                                        <igWPF:FieldSettings.EditorStyle>
                                            <Style TargetType="{x:Type igWPF:XamComboEditor}">
                                                <Setter Property="ItemsSource" Value="{Binding DataItem.fejl}"/>
                                            </Style>
                                        </igWPF:FieldSettings.EditorStyle>
                                    </igWPF:FieldSettings>
                                </igWPF:ComboBoxField.Settings>
                            </igWPF:ComboBoxField>

    You can find the sample attached below. If you require any further assistance on the matter, please let me know.

    Sincerely,

    Bozhidara Pachilova,

    Associate Software Developer

    5736.XDGWithComboField.zip