title: change data grid based on combobox selection WPF
body: <p>I am trying to populate a datagrid based on the selection from a combobox, I am new to wpf so I am not sure if my issue is the the databinding or what.  Here is my VM:</p>
  
  <pre><code>namespace WasteTracker
  {
  public class MenuItemViewModel : INotifyPropertyChanged
  {
  
      DataSource data = new DataSource();
  
      private ObservableCollection&lt;StationList&gt; stationlistcb = new 
          ObservableCollection&lt;StationList&gt;();
      private ObservableCollection&lt;MenuItem&gt; menuitemdg = new 
          ObservableCollection&lt;MenuItem&gt;();
  
      //methods to populate combobox of stations and datagrid of menu items 
                 for that station
      #region Load Stations and Menu Methods
      public void LoadStationList()
      {
          stationlistcb = new ObservableCollection&lt;StationList&gt;
                              (data.Stations());
      }
  
      public void LoadMenuItems(int stationid)
      {
          menuitemdg = new ObservableCollection&lt;MenuItem&gt;
              (from onemenuitem in data.MenuItems()
               where onemenuitem.StationId.Equals(stationid)
               select onemenuitem);
  
          OnPropertyChanged("MenuItemData");
      }
      #endregion
  
      public ObservableCollection&lt;StationList&gt; StationList
      {
          get
          {
              return stationlistcb;
          }
      }
  
      public ObservableCollection&lt;MenuItem&gt; MenuItemList
      {
          get
          {
              return menuitemdg;
          }
      }
  
      /// &lt;summary&gt;
      /// Called when [property changed].
      /// &lt;/summary&gt;
      /// &lt;param name="PropertyName"&gt;Name of the property.&lt;/param&gt;
      protected void OnPropertyChanged(string PropertyName)
      {
          VerifyPropertyName(PropertyName);
  
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new 
                                      PropertyChangedEventArgs(PropertyName));
          }
      }
  
      #region Propertychange Methods
      /// &lt;summary&gt;
      /// Warns the developer if this object does not have
      /// a public property with the specified name. This 
      /// method does not exist in a Release build.
      /// &lt;/summary&gt;
      [Conditional("DEBUG")]
      [DebuggerStepThrough]
      private void VerifyPropertyName(string propertyName)
      {
          // Verify that the property name matches a real,  
          // public, instance property on this object.
          if (TypeDescriptor.GetProperties(this)[propertyName] == null)
          {
              string msg = "Invalid property name: " + propertyName;
              throw new Exception(msg);
          }
      }
      #endregion
  
      public event PropertyChangedEventHandler PropertyChanged;
     }
  }
  </code></pre>
  
  <p>And here is the XAML for the page:</p>
  
  <pre><code>    &lt;TextBlock Grid.Row="0" Grid.ColumnSpan="3" FontSize="35" 
        HorizontalAlignment="Center" VerticalAlignment="Top" Text="Microsoft 
        SVMT Waste Tracker" Height="50"  Width="480"  Margin="44,0" /&gt;
      &lt;TextBlock Grid.Row="1" Grid.ColumnSpan="3" FontSize="30" 
         HorizontalAlignment="Center" VerticalAlignment="Top" Text="Waste 
         Entry"  Height="50" Width="166"  Margin="10,0,44,0" /&gt;
  
      &lt;TextBlock Grid.Row="2" Grid.Column="0" Text="Station" FontSize="30"  
        HorizontalAlignment="Center" VerticalAlignment="top" /&gt;
  
      &lt;TextBlock Grid.Row="2" Grid.Column="3" Text="Date" FontSize="30" 
        HorizontalAlignment="Center" VerticalAlignment="top" /&gt;
      &lt;DatePicker Grid.Row="3" Grid.Column="2" Grid.RowSpan="2" FontSize="30" 
                  HorizontalAlignment="Center" VerticalAlignment="Center" 
                  Width="290" Height="42" Margin="0,19,10,22" /&gt;
  
      &lt;ComboBox  Name="StationBox" Grid.Row="3" Grid.Column="0" 
       Grid.RowSpan="2" FontSize="30" ItemsSource="{Binding StationList}" 
                 DisplayMemberPath="StationName" HorizontalAlignment="Center" 
            VerticalAlignment="Center" Width="300" Height="42" 
            Margin="0,19,0,23" 
                 SelectionChanged="Station_SelectionChanged" /&gt;
  
      &lt;DataGrid ItemsSource="{Binding MenuItemList}" 
         DisplayMemberPath="MenuItemText" AutoGenerateColumns="False" 
         Grid.Row="5" Grid.ColumnSpan="3" CanUserAddRows="True" 
        AlternatingRowBackground="AliceBlue" 
        IsSynchronizedWithCurrentItem="True" &gt;
  
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Header="Menu Item" Binding="{Binding 
                MenuItemText}" HeaderStyle="{StaticResource CenterGridHeader}" 
                CellStyle="{StaticResource CenterCellText}" 
                                  IsReadOnly="True" CanUserResize="False" 
                FontSize="36" Width="*"/&gt;
              &lt;DataGridTextColumn Header="UoM" Binding="{Binding UoM}" 
               HeaderStyle="{StaticResource CenterGridHeader}" CellStyle="
               {StaticResource CenterCellText}" 
                                  IsReadOnly="True" FontSize="36" 
              CanUserResize="False" Width="*" /&gt;
              &lt;DataGridTextColumn Header="Left Over" Binding="{Binding 
                 UserInput}" HeaderStyle="{StaticResource CenterGridHeader}" 
                 CellStyle="{StaticResource CenterCellText}" 
                                  FontSize="36" IsReadOnly="False" 
                 CanUserResize="False" Width="*"/&gt;
              &lt;DataGridTextColumn Header="UoM" Binding="{Binding UoM}" 
                HeaderStyle="{StaticResource CenterGridHeader}" CellStyle="
                {StaticResource CenterCellText}" 
                                  IsReadOnly="True" FontSize="36" 
               CanUserResize="False" Width="*" /&gt;
              &lt;DataGridTextColumn Header="Par" Binding="{Binding Par}" 
               HeaderStyle="{StaticResource CenterGridHeader}" CellStyle="
               {StaticResource CenterCellText}" 
                                  IsReadOnly="True" FontSize="36" 
               CanUserResize="False" Width="*"/&gt;
              &lt;DataGridTextColumn Header="UoM" Binding="{Binding UoM}" 
                HeaderStyle="{StaticResource CenterGridHeader}" CellStyle="
               {StaticResource CenterCellText}" 
                                  IsReadOnly="True" FontSize="36" 
           CanUserResize="False" Width="*" /&gt;
          &lt;/DataGrid.Columns&gt;
  
      &lt;/DataGrid&gt;
  
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>this is the xaml.cs:</p>
  
  <pre><code>public MenuItemViewModel _objViewModel = new MenuItemViewModel();
  
      public EnterWaste()
      {
          InitializeComponent();
          SourceContext();
          InitialOperations();
      }
  
     private void Station_SelectionChanged(object sender, 
      SelectionChangedEventArgs e)
      {
          _objViewModel.LoadMenuItems((StationBox.SelectedItem as 
       MenuItem).StationId);
  
      }
  </code></pre>
  
  <p>With this code currently the combobox is currently populated with the correct info, however when I make a selection from the combobox the datagrid will not display the correct info.  Being new to wpf I have done a lot googling however the closest thing I can find in cascading comboboxes, and that solution really didn't help.  Any suggestions would be appreciated.</p>