title: Conditional binding from view model to view in WPF using MVVM pattern
body: <p>I am developing a WPF application using MVVM pattern. I have a combo in the view and two lists in the viewmodel (projects and organizations). Depending on the organizations list items I have to bind the the name of the organization or not. 
  For example if the Count property of the organizations list is 1 the combobox item have to be <strong>"ProjectName"</strong>, and if the Count property of the organizations list is greater than 1 the combobox item should look like <strong>"ProjectName - OrganizationName"</strong>.
  This is the XAML code I have:</p>
  
  <pre><code>&lt;ComboBox x:Name="textBox3" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{Binding Path=Projects}" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=SelectedProject}"&gt;
          &lt;/ComboBox&gt;
  </code></pre>
  
  <p>How should I achieve this purpose. I hope for a little help. Cheers.</p>
  
  <p>I added the property projectFullName in the viewmodel but I got an empty combobox:</p>
  
  <pre><code> public string ProjectFullName
      {
          get
          {
              if (this.organizations.ToList().Count &gt; 1)
              {
                  this.projectFullName = string.Format("{}{0} - {1}", this.selectedProject.Name, this.organizations.First(org =&gt; org.Id == this.selectedProject.OrganizationId).Name);
              }
              else if (this.organizations.ToList().Count == 1)
              {
                  this.projectFullName = this.selectedProject.Name;
              }
              return this.projectFullName;
          }
      }
  </code></pre>
  
  <p>XAML code:</p>
  
  <pre><code>&lt;ComboBox x:Name="textBox3" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{Binding Path=Projects}" DisplayMemberPath="{Binding Path=ProjectFullName}" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=SelectedProject}"&gt;
  
          &lt;/ComboBox&gt;
  </code></pre>