I know in ASP.NET I can get an item from a DropDownList by using
DropDownList1.Items.FindByText
Is there a similar method I can use in WPF for a ComboBox?
Here’s the scenario.
I have a table called RestrictionFormat that contains a column called RestrictionType, the type is a foreign key to a table that stores these values.
In my editor application I’m writing, when the user selects the RestrictionFormat from a ComboBox (this works fine), I’m pulling up the details for editing. I’m using a second ComboBox to make sure the user only selects one RestrictionType when editing. I already have the second combobox bound property from the RestrictionType table, but I need to change the selected index on it to match the value specified in the record.
Here’s the scenario.
I have a table called RestrictionFormat that contains a column called RestrictionType, the type is a foreign key to a table that stores these values.
In my editor application I’m writing, when the user selects the RestrictionFormat from a ComboBox (this works fine), I’m pulling up the details for editing. I’m using a second ComboBox to make sure the user only selects one RestrictionType when editing. I already have the second combobox bound property from the RestrictionType table, but I need to change the selected index on it to match the value specified in the record.
Does this make sense?
Can you use ItemContainerGenerator?
ItemContainerGenerator contains a ContainerFromItem method that takes an object parameter. If you have a reference to the full object that your comboBox contains (or a way to reconstruct it), you can use the following: