title: Combobox selectedvalue and override ToString() - MVVM WPF
body: <p>I have a combobox which displays data from an override <code>ToString()</code>. I also have a datagrid text column that also gets its values from override <code>ToString()</code>.</p>
  
  <p>What I want is to sync the combobox to the datagrid so that when we click on a datagird row it shows the same value in the combobox and when we change the value in a combobox it updates the datagrid cell. </p>
  
  <p>The problem is that I can't seem to figure out how to do it with <code>ToString()</code>. It works when I bind it to a property with a getter and a setter. But I need it to be on <code>ToString()</code>.</p>
  
  <p>Model</p>
  
  <pre><code>  public class SifKorisnici: INotifyPropertyChanged
      {
          private string _ime;
          private string _prezime;
  
          public string Ime
          {
              get { return _ime; }
              set
              {
                  _ime = value;
                  OnPropertyChanged("Ime");
              }
          }
  
          public string Prezime
          {
              get { return _prezime; }
              set
              {
                  _prezime = value;
                  OnPropertyChanged("Prezime");
              }
          }
  
          public override string ToString()
          {
              return Prezime + " " + Ime;
          }
      }
  </code></pre>
  
  <p>Datagrid</p>
  
  <pre><code>  &lt;DataGrid ItemsSource="{Binding ListaOdjeli,Mode =TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                    AutoGenerateColumns="False" CanUserAddRows="False" Margin="0,180,0,0"
                    IsReadOnly="True"
                    IsSynchronizedWithCurrentItem="True"
                    SelectedItem="{Binding SelectedItems,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"&gt;
              &lt;DataGrid.Columns&gt;
  
                  &lt;DataGridTextColumn Header="Voditelj" Binding="{Binding SifKorisnici,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"/&gt;
          &lt;/DataGrid&gt;
  
  </code></pre>
  
  <p>Combobox</p>
  
  <pre><code>  &lt;ComboBox Name="OdaberiKorisnika" ItemsSource="{Binding ListaKorisnikaCombo, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                    HorizontalAlignment="Left" Margin="111,142,0,0" VerticalAlignment="Top" 
                    Width="120" 
                    IsReadOnly="True"
                    IsSynchronizedWithCurrentItem="True"
                    SelectedItem="{Binding SelectedKorisnici,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                    SelectedValue="{Binding SelectedItems.SifKorisnici??,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                    SelectedValuePath="SifKorisnici??"
  
                    IsEnabled="{Binding JeOmogucenGumb}"
          &lt;/ComboBox&gt;
  
  </code></pre>