Search code examples
wpfcomboboxcollectionviewsourceselectedvalueicollectionview

ComboBox SelectedValue correctly sets SelectedValue in Viewmodel but not in View


In my Project my selectedvalue sets correctly in viewmodel but my view not sets its selectedvalue

in xaml code:

 <ComboBox ItemsSource="{Binding AllValues}" SelectedValue="{Binding SelectedValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="5,0,0,0">

in ViewModel:

public Model SelectedValue
        {
            get
            {
                return _model.Value;
            }
            set
            {
                 _model.Value = value;
                if (CVSCollection.View != null)
                    CVSCollection.View.Refresh();
                RaisePropertyChanged("SelectedValue");
            }
        }

Solution

  • I have solved by my own as i have set local variable for selectedvalue as _selectedValue and into constructor i have set _selectedValue..