Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Maybe you know that ComboBox has SelectedItem.

This ComboBox have this itemsSource(1, 2, 3, 4).

And I want to set anything(1 or 2).

If I use SelectedIndex, it is easy. [SelectedIndex = 1;] <= well done.

But I want to Bind this value using SelectedItem.

I already test like this.

XML
<ComboBox x:Name="cbOperatingType" ItemsSource="{Binding mUserGroupList}" SelectedItem="{Binding mDGSelectedItem.m_Operator_Type, Mode=TwoWay}" />


Binding ItemsSource is well done. But Binding SelectedItem is not operating.

When Program is run, ComboBox's TextBlock is empty

mUserGroupList & mDGSelectedItem.m_Operator_Type is also property(have get, set)

Please tell me answer for this problem.
Please suggest solution for this problem.
Posted
Updated 24-Feb-11 2:15am
v2

1 solution

You have to set the DisplayMemberPath to the combobox.
Now it should work.

XML
<ComboBox x:Name="cbOperatingType" ItemsSource="{Binding mUserGroupList}" DisplayMemberPath="{Binding Path=mDGSelectedItem.m_Operator_Type, Mode=TwoWay}" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900