I have this class
public class AvisTIlGrid { public decimal avis_tillæg { get; set; } public decimal andet_tillæg {get; set;} public string webtillæg_type { get; set; } public decimal oldTotalPris { get; set; } public double? sum_bladtilæg { get; internal set; } public List<webtilLæg> webtillages { get; set; }
public decimal? calTotalPris() { return this.Farve4Max + Farve4Min + Farve4Pris + FarveMax + FarveMin + FarvePris; }
public class webtilLæg { public string type { get; set; } public int wbId { get; set; } public double? wpPris { get; set; } }
and I want to bind the List<webtilLæg> webtillages to a combobox in the xamdatagrid
I have tried like this
<igWPF:ComboBoxField Name="Webtillages" ItemsSource="{Binding Path=Webtillages }" DisplayMemberPath="{Binding Path=type}"></igWPF:ComboBoxField>
Hello Thomas,
In order to bind the xamComboBox to a collection, you will need to expose this collection to the presentation layer of your application.
The first approach of this would be to create a viewModel, and bind the DataContext to it. Please check the following thread for this approach.
The other option would be to create an ObjectDataProvider to bind to data. More information about this path can be read on our website here.
Should you have any further questions, please let me know.
Sincerely,Tihomir TonevAssociate Software Developer
but how do I get the type of the webtillæg class showed,
Once you have successfully bound the ItemsSource of the field to your collection of objects(webtilLæg), you have to point to the property you want displayed - DisplayMemberPath="type".
In case you cannot expose the collection and wrap it in the presentation layer of your application, you can instead just use a re-template a field, by setting its editor to a XamComboEditor, who can be bound to the DataContext.
For further reference, I have created a sample to demonstrate how to do the binding. Please check the attached solution.
Should you have any further questions, I'll be happy to help.
ComboBoxData.zip