title: Binding Context Menu To A View Model Property
body: <p>I have a context menu that is tied to a button in a datagrid.  I want the context menu items to change based on a list of strings that I have in my view model. When I click the button, nothing shows up.</p>
  
  <p>Here is the xaml I am using, which is in a datagrid:</p>
  
  <pre><code>&lt;Button Grid.Column="1" Content="..."  Click="Button_Click"&gt;
          &lt;Button.ContextMenu&gt;
         &lt;ContextMenu ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Path=DataContext.SelectableDescriptions}"&gt;    
           &lt;TextBlock Text="{Binding}"/&gt;
         &lt;/ContextMenu&gt;
         &lt;/Button.ContextMenu&gt;        
  &lt;/Button&gt;
  </code></pre>
  
  <p>Here's the whole DataGrid xaml:</p>
  
  <pre><code>&lt;DataGrid Grid.Row="1" Grid.ColumnSpan="4" CanUserAddRows="True" AutoGenerateColumns="False" CanUserDeleteRows="True"  ItemsSource="{Binding JobPricings, Mode=TwoWay}" SelectedItem="{Binding SelectedJobPricing, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" &gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTemplateColumn  Header="Description" Width="25*"   &gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="75*"/&gt;
                              &lt;ColumnDefinition Width="25*"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;TextBox Grid.Column="0" Text="{Binding Description,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/&gt;
                          &lt;Button Grid.Column="1" Content="..."  Click="Button_Click"&gt;
                              &lt;Button.ContextMenu&gt;
                                  &lt;ContextMenu ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Path=DataContext.SelectableDescriptions}"&gt;
                                      &lt;TextBlock Text="{Binding}"/&gt;
                                  &lt;/ContextMenu&gt;
                              &lt;/Button.ContextMenu&gt;
                          &lt;/Button&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
           &lt;/DataGridTemplateColumn&gt;
          &lt;DataGridTextColumn Header="Unit Price" Binding="{Binding UnitPrice, Mode=TwoWay}" Width="25*"/&gt;
          &lt;DataGridTextColumn Header="Unit" Binding="{Binding Unit, Mode=TwoWay}" Width="25*"/&gt;
          &lt;DataGridTemplateColumn  Header="Currency   " Width="25*" &gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid&gt;
                          &lt;ComboBox  SelectedValue="{Binding CurrencyID, Mode=TwoWay}" SelectedValuePath="ID" DisplayMemberPath="Description" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Path=DataContext.Currencies}"  &gt;&lt;/ComboBox&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Here is the property that I am binding the context menu to through my view model:</p>
  
  <pre><code>public ObservableCollection&lt;string&gt; SelectableDescriptions
  {
      get
      {
          _selectableDescriptions.Add("One");
          _selectableDescriptions.Add("Two");
          return _selectableDescriptions;
      }
      set
      {
          _selectableDescriptions = value;
      }
  }
  </code></pre>
  
  <p>Any ideas of why my list won't show up in the context menu? </p>