I'd like to bind a GraphicsCollection (which is a property in a view model) to a combo box in a XAML window. The problem is I can't figure out how to display attribute values in the combo box. I can get it to display the Geometry property like this:
<ComboBox DataContext="{StaticResource MyViewModel}"
DisplayMemberPath="Geometry"
ItemsSource="{Binding CollectionOfGraphics}" />
But I want to be able to do something like this that will display the OBJECTID or some other attribute:
<ComboBox DataContext="{StaticResource MyViewModel}"
DisplayMemberPath="Attributes["OBJECTID"]"
ItemsSource="{Binding CollectionOfGraphics}" />
I also tried this approach - unsuccessfully:
<ComboBox DataContext="{StaticResource MyViewModel}"
DisplayMemberPath="Attributes[0]"
ItemsSource="{Binding CollectionOfGraphics}" />
Platform: ArcGIS 10.1, WPF Runtime 10.1.1
Solution based on Antti Kajanus's answer below:
<ComboBox DataContext="{StaticResource MyViewModel}"
ItemsSource="{Binding CollectionOfGraphics}" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Attributes[OBJECTID]}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Note that the attributite name (OBJECTID) did not have to be quoted.