stevenjmyu
stevenjmyu

Reputation: 946

Getting the DisplayMemberPath value of combobox in Silverlight

I have a silverlight app that populates a combobox from a sharepoint list.

here's the assignment of the combobox and I was able to bind to the combobox using an INotifyProperty. I am stuck on how to go about getting the value of the Display Member of the combobox.

<ComboBox Name="cboAwardType" SelectedValue="{Binding SelectedAwardType, Mode=TwoWay}"
                    ItemsSource="{Binding}" DataContext="{Binding}" />

code behind

  void _hrwebservice_GetAwardTypesCompleted(object sender, GetAwardTypesCompletedEventArgs e)
    {
        List<AwardType> awardTypes = (List<AwardType>)e.Result.ToList();
        cboAwardType.ItemsSource = awardTypes;
        cboAwardType.DisplayMemberPath = "AType";
        cboAwardType.SelectedValuePath = "ID";           
    }

I can see the value in the SelectedItem. How do i access that AType value?

enter image description here

Upvotes: 0

Views: 971

Answers (2)

Ejrr1085
Ejrr1085

Reputation: 1071

  string selectedType = cboAwardType.Text;

Upvotes: 0

Memoizer
Memoizer

Reputation: 2279

Maybe...

var selectedType = ((AwardType) cboAwardType.SelectedItem).AType; 

Upvotes: 1

Related Questions