title: Binding with Relativesource --wpf
body: <p>I have a short question:</p>
  
  <p>I have a datagrid and binded it to something. Then I put a combobox in a column and binded it to another source by </p>
  
  <pre><code>ItemsSource="{Binding DataContext.Users, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}" 
  </code></pre>
  
  <p>Now I want to use datagrid's source again, in the combobox again.That code doesn't work now and I know that there is a ID column in datagrid's source.</p>
  
  <pre><code>SelectedValue="{Binding ID}"
  </code></pre>
  
  <p>How can I fix it? Thanks in advance.</p>
  
  <p>And here is my whole DataGrid and the problematic part is the combobox.</p>
  
  <pre><code> &lt;DataGrid ItemsSource="{Binding SCs}" SelectedItem="{Binding SelectedSC}" Margin="0,10,0,0"
              RowStyle="{StaticResource ResourceKey=DataGridRowStyle}" Style="{DynamicResource ResourceKey=UILDataGridStyle}" AutoGenerateColumns="False" EnableRowVirtualization="True" 
              RowDetailsVisibilityMode="VisibleWhenSelected" Width="Auto" IsReadOnly="True" Background="Transparent"
              VerticalAlignment="Stretch" HorizontalAlignment="Stretch" GridLinesVisibility="Vertical" VerticalGridLinesBrush="{DynamicResource ResourceKey=UILBorderBrush}"
              RowHeaderWidth="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" BorderBrush="{DynamicResource ResourceKey=UILBorderBrush}"
              BorderThickness="1" SelectionUnit="FullRow" SelectionMode="Single" x:Name="SCDataGrid"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn x:Name="securityConfigurationIDColumn"  Binding="{Binding Path=SecurityConfigurationID}" Header="Security Configuration ID" Width="*" /&gt;
              &lt;DataGridTextColumn x:Name="securityConfigurationNameColumn" Binding="{Binding Path=SecurityConfigurationName}"  Header="Security Configuration Name" Width="*" /&gt;
              &lt;DataGridTemplateColumn x:Name="proxyResponsibleUser_IDColumn"   Header="Proxy Responsible User ID" Width="*" &gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;ComboBox IsEnabled="True"  ItemsSource="{Binding DataContext.Users, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
                                    SelectedValuePath="{Binding UserID}"  DisplayMemberPath="{Binding FullName}" Width="117" Height="20" 
                                    SelectedValue="{Binding ProxyResponsibleUser_ID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /&gt;
  
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
  
              &lt;DataGridTextColumn x:Name="responsibleUser_IDColumn" Binding="{Binding Path=User.FullName}" Header="Responsible User ID" Width="*" /&gt;
              &lt;DataGridTextColumn x:Name="securityConfigurationDescriptionColumn" Binding="{Binding Path=SecurityConfigurationDescription}" Header="Security Configuration Description" Width="*" /&gt;
              &lt;DataGridTextColumn x:Name="securityConfigurationURLColumn" Binding="{Binding Path=SecurityConfigurationURL}" Header="Security Configuration URL" Width="*" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt; 
  </code></pre>