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
605
How can I bind the XamComboEditor to a DataTable in XAML?
posted

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 

 

  • 350
    posted

    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:

     

            private static DataTable _dtsites = new DataTable();


                var rsSites = (ComboBoxItemsProvider)this.Resources["SiteProviderKey"];
                rsSites.ItemsSource = (IEnumerable)_dtsites;

     Hope this helps!


    Wade