Jonathan Allen
Jonathan Allen

Reputation: 70287

WPF: Databinding with ComboBox

The below code works for a DataGridComboBoxColumn, but ComboBox doesn't have a SelectedValueBinding property. What should I use instead?

<ComboBox
    Header="Application"  
    SelectedValueBinding="{Binding ApplicationKey}" 
    SelectedValuePath="ApplicationKey"  
    DisplayMemberPath="ApplicationName"  
    ItemsSource="{Binding Source={x:Static app:ApplicationLookup.GetAllOrNone}}"/> 

Upvotes: 0

Views: 115

Answers (1)

TerrorAustralis
TerrorAustralis

Reputation: 2923

Use
SelectedValue = {Binding Property}
or SelectedItem = {Binding Property}

these will have the same effect
and to get the Path that you want to display use
DisplayMemberPath = Property

Upvotes: 1

Related Questions