Well:
View:
<ComboBox ItemsSource="{Binding SourceData}" SelectedItem="{Binding SelectedSourceData,Mode=TwoWay}"/> <TextBlock Text="{Binding SelectedDataInTextFormat}"/>
ViewModel:
public class ViewModel:ViewModelBase { public ObservableCollection<Foo> SourceData{get;set;} public Foo SelectedSourceData { get{return _selectedFoo;} set{_selectedFoo=value; RaisePropertyChanged("SelectedSourceData"); SelectedDataInTextFormat=Foo.ToString(); } public string SelectedDataInTextFormat { get{return _selectedDataInTextFormat;} set{_selectedDataInTextFormat=value; RaisePropertyChanged("SelectedDataInTextFormat"); } }
Basically, so that your view model can get the updated selected item from the drop-down list, make sure that the SelectedItem binding is set to Mode = TwoWay. To make sure that you push data from the viewmodel into the view when a change in the viewmodel occurs, make sure you call the RaisePropertyChanged helper class for the property that you want to update in the view.
source share