I have a ListCollectionView which holds a bunch of Items of object Scene. One of the properties in Scene is Location.
When I navigate through the ListCollectionView I want to set the value of the Location property as SelectedItem in a comboBox in the View. Each time I go to a different item in the ListCollectionView I want to show the new location as SelectedItem in the comboBox.
I know how to make this work in a regular TextBox and TextBlock, but not in a ComboBox.
ViewModel
public ListCollectionView SceneCollectionView { get; set; }
private Scene CurrentScene
{
get { return SceneCollectionView.CurrentItem as Scene; }
set
{
SceneCollectionView.MoveCurrentTo(value);
RaisePropertyChanged();
}
}
View
<ComboBox SelectedItem="{Binding SceneCollectionView/Location, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding AllLocations}}"/>
For textboxes following works perfectly, but not for comboBoxes
<TextBox Text="{Binding SceneCollectionView/Location, UpdateSourceTrigger=PropertyChanged}"/>
Any Idea how I can get the same behavior in for SelectedItem in ComboBox. I'm fairly new to coding in c#
Location
property? – Bahman_Aries