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
20
ComboBoxItemsProvider and ObjectDataProvider
posted

Is it possible to bind the ItemsSource of the ComboBoxItemsProvider to an ObjectDataProvider?  I was under the impression that with normal ComboBoxes and other ItemsControls this was possible.  Is there something different about the ComboBoxItemsProvider that doesn't allow this?  I get this error when I try:

Cannot convert the value in attribute 'ItemsSource' to object of type 'System.Collections.IEnumerable'. 'System.Windows.Data.ObjectDataProvider' is not a valid value for property 'ItemsSource'.

This works fine with a normal ComboBox.

Here's a snippet of my XAML:

<UserControl.Resources>
...
        <ObjectDataProvider ObjectType="{x:Type bll:LocationManager}"
                            x:Key="locationProvider"
                            MethodName="GetLocations">
            <ObjectDataProvider.MethodParameters>
                <s:Int32>1</s:Int32>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <igEditors:ComboBoxItemsProvider x:Key="locationItemsProvider"
                                        ItemsSource="{StaticResource locationProvider}"
                                        ValuePath="LocationID"
                                        DisplayMemberPath="LocationDesc"
                                        >
       </igEditors:ComboBoxItemsProvider>
</UserControl.Resources>

GetLocations returns a List.

And of course further down in the XAML my XamComboBox binds to the ItemsProvider.  Any help would be appreciated!

Thanks!

Parents
  • 9694
    posted

    My initial look at your XAML, I would think you would need to assign the ItemsSource using the Binding syntax, such as:

    ItemsSource="{Binding Source={StaticResource locationProvider}}"

    I will check with an engineer to see what insights he may have about this issue and post his response.

    Thank you,

Reply Children
No Data