Binding to a listbox and selected item using Caliburn Micro

This will work with a listbox or combo box.

So, using Caliburn Micro we use convention based naming for the ItemsSource as follows

<ListBox x:Name="Employees" />

But as you see there’s nothing for SelectedItem, instead it is taken that the property name in the view model for the selected item will be SelectedEmployee, i.e.

public class EmployeesViewModel : PropertyChangedBase
{
   private EmployeeViewModel selected;

   public ObservableCollection<EmployeeViewModel> Employees { get; private set; }

   public EmployeeViewModel SelectedEmployee
   {
      get { return selected; }
      set
      {
         if (selected != value)
         {
            selected = value;
            NotifyOfPropertyChange();
         }
      }
   }
}