Reputation: 29
how can show value of selected item in combobox in textblock ?
i use this code to get value .
combobox20.ItemsSource = database.Mavads.ToList();
combobox20.DisplayMemberPath = "MavadName";
combobox20.SelectedValuePath = "MavadFe";
I try to get it with this code
txt_f1.Text = combobox1.SelectedValuePath ;
but show me "MavadFe"
i use event "IsMouseCapturedChanged"
Upvotes: 2
Views: 73
Reputation: 66499
The SelectedValuePath
sets the field used to represent whatever item you've selected, but to get the actual selected value you need SelectedValue
. It's an object, so assuming the "MavadFe" field is a string, just convert it.
private void combobox20_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
txt_f1.Text = combobox1.SelectedValue.ToString();
}
Upvotes: 2