I have two properties, one which is a list of string and the other just a string.
private List<String> _property;
public List<String> Property
get
{
return new List<string>(){"string1", "string2"};
}
set{_property = value
}
public String SimpleStringProperty{get;set;}
I also have a Combobox defined in XAML as such
<Combobox ItemsSource="{Binding Property , Mode="TwoWay"}" Text="Select Option" />
Now the combobox correctly displays two options :"string1" and "string2"
When the user selects one or the other, I want to set SimpleStringProperty
with that value. However, the 'value' im getting back from the combobox through the two way binding is not the selectedItem, but the List<String>
. How can I do this right? I'm fairly new to wpf, so please excuse the amateurism.
<Combobox ItemsSource="{Binding Property}" SelectedItem="{Binding SimpleStringProperty, Mode=TwoWay}" Text="Select Option" />
That's untested, but it should at least be pretty close to what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With