views:

530

answers:

1

I have a MainWindow.xaml (which consists of a TabControl) and a few UserControls (which are loaded into the TabItems). One particular UserControl has a WPFToolkit DataGrid with custom columns (not auto-generated). One of these columns is a ComboBox-type column that binds to a property in my model called "Status". I also have an Enum for Status called "FollowUpStatus". This ComboBox column is declared as follows:

<WpfTK:DataGridComboBoxColumn 
   Header="Status" 
   SelectedItemBinding="{Binding Status}" 
   ItemsSource="{Binding Source={StaticResource FollowUpStatusProvider}}" />

The FollowUpStatusProvider is an ObjectDataProvider declared as follows at the application resources level - visible to both MainWindow and all UserControls:

<ObjectDataProvider x:Key="FollowUpStatusProvider"
   MethodName="GetValues" ObjectType="{x:Type DAL:FollowUpStatus}">
    <ObjectDataProvider.MethodParameters>
     <x:Type TypeName="DAL:FollowUpStatus"/>
    </ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

It all works fine at run-time. At design time, from MyUserControl.xaml, the designer renders it ok. But my MainWindow complains it cannot "create an instance of type 'MyUserControl'". The code that's causing MainWindow to choke is the assignment to ItemsSource in the ComboBox column:

... ItemsSource="{Binding Source={StaticResource FollowUpStatusProvider}}" ...

If I remove this assignment, it all works as expected.

Can somebody help me understand why and how to fix it?

Thanks!

A: 

Have you tried

... ItemsSource="{StaticResource FollowUpStatusProvider}"
Tri Q
You cannot bind to an ObjectDataProvider using this syntax.
Gustavo Cavalcanti