Hello
How can I bind the XamComboEditor to a DataTable (created in the CodeBehind-File) in XAML?
If I define it in the Code-Behind-File, it works, but how can I define it in the XAML-File?
Code-Behind:
Me.XamComboEditor1.ItemsProvider.ItemsSource = dt
Me.XamComboEditor1.ItemsProvider.DisplayMemberPath = "Name"Me.XamComboEditor1.ItemsProvider.ValuePath = "Id"
But how does it works in the XAML-File?
<igEditors:XamComboEditor ... >
<igEditors:XamComboEditor.ItemsProvider> <igEditors:ComboBoxItemsProvider ItemsSource= ????? DisplayMemberPath="Name" ValuePath="Id" /></igEditors:XamComboEditor.ItemsProvider>
</igEditors:XamComboEditor>
I hope, you can help me.
Thanks
Here is what I had to do:
XAML:
<Window.Resources> <igEditors:ComboBoxItemsProvider x:Key="SiteProviderKey" ValuePath="SiteId" DisplayMemberPath="Site"> </igEditors:ComboBoxItemsProvider> </Window.Resources>
DOWN IN MY DATAGRID FIELD LAYOUT:
<!--Field Layout for the SiteID --> <igDP:Field Name="SiteId"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource SiteProviderKey}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
CODE BEHIND:
Member Level Variable
private static DataTable _dtsites = new DataTable();
Window Load Event:
var rsSites = (ComboBoxItemsProvider)this.Resources["SiteProviderKey"]; rsSites.ItemsSource = (IEnumerable)_dtsites;
Hope this helps!
Wade