Reputation: 143
I cannot seem to bind my ComboBox
to an array.
I have this ObjectDataProvider
:
<ObjectDataProvider x:Key="TypeFromEnum" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="property:Property:PropertyType"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
And this binding:
<DataTemplate x:Key="TypeCellTemplate">
<ComboBox ItemsSource="{Binding Path={StaticResource TypeFromEnum}}" SelectedItem="{Binding Path=Type}"/>
</DataTemplate>
But I get the error:
Invalid resource type: expected type is 'PropertyPath', actual type is 'Array'.
And when I run my program and try to open the window with this ComboBox
, then it crashes:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: 'Provide value on 'System.Windows.Markup.TypeExtension' threw an exception.' Line number '8' and line position '12'.
If there is a handler for this exception, the program may be safely continued.
Upvotes: 0
Views: 410
Reputation: 18580
Set ObjectDataProvider
as Source
of Binding
not Path
:
<ComboBox ItemsSource="{Binding Source={StaticResource TypeFromEnum}}" />
Upvotes: 2