title: Usercontrol using wrong Datacontext
body: <p>I have a UserControl that is used in a parent control in this way:</p>
  
  <pre><code>&lt;Views:TranslationTextInput  Translation="{Binding SelectedEntity.Name}"/&gt;
  </code></pre>
  
  <p>The parent control DataContext is a ViewModel containing the SelectedEntity Property.</p>
  
  <p>In my child UserControl I define a new ViewModel as the DataContext:</p>
  
  <pre><code>    &lt;UserControl.DataContext&gt;
        &lt;vm:TranslationTextInputViewModel x:Name="vm"&gt;&lt;/vm:TranslationTextInputViewModel&gt;
      &lt;/UserControl.DataContext&gt;
  </code></pre>
  
  <p>In the code behind I have:</p>
  
  <pre><code>    public static readonly  DependencyProperty TranslationProperty = DependencyProperty.Register("Translation", typeof(Translation),typeof(UserControl));
  
      // .NET Property wrapper
      public Translation Translation
      {
          get { return (Translation)GetValue(TranslationProperty); }
          set { SetValue(TranslationProperty, value); }
      }
  
  
   public TranslationTextInput(){
       InitializeComponent();
       DataContext = new TranslationTextInputViewModel();
       SetBinding(TranslationProperty,   new Binding { Path = new PropertyPath     ("Translation"), Mode = BindingMode.OneWayToSource });
  </code></pre>
  
  <p>When executed I get a Binding error:</p>
  
  <pre><code>System.Windows.Data Error: 40 : BindingExpression path error: 'SelectedEntity' property not found on 'object' ''TranslationTextInputViewModel' (HashCode=49954236)'. BindingExpression:Path=SelectedEntity.Name; DataItem='TranslationTextInputViewModel' (HashCode=49954236); target element is 'TranslationTextInput' (Name='InputControl'); target property is 'Translation' (type 'Translation')
  </code></pre>
  
  <p>It seems the SelectedEntity is looked up on the child UserControl's Viewmodel, but the Property of the parent ViewModel should be used. How can I solve this?</p>
  
  <p>Edit:</p>
  
  <pre><code>    public TranslationTextInputViewModel()
      {
          //EnglishTranslation = tranlsations["en"];
      }
  
      public string EnglishTranslation
      {
          get
          {
              if (!Translation.TranslationDict.ContainsKey(new CultureInfo("en").LCID))
                  Translation.Translations.Add(new TranslationItem() { Text = "", Lcid = new CultureInfo("en").LCID });
              return Translation.TranslationDict[new CultureInfo("en").LCID].Text;
          }
          set
          {
              Translation.TranslationDict[new CultureInfo("en").LCID].Text = value;
          }
  
      }
  
      public string SelectedTranslation
      {
          get
          {
              if (!Translation.TranslationDict.ContainsKey(_selectedLanguage))
                  Translation.Translations.Add(new TranslationItem() { Text = "", Lcid = _selectedLanguage });
              return Translation.TranslationDict[_selectedLanguage].Text;
  
          }
  
          set
          {
              Translation.TranslationDict[_selectedLanguage].Text = value;
          }
      }
  
      private Translation _translation;
  
      public Translation Translation
      {
          get
          {
              if (_translation == null)
                  _translation = new Translation();
              return _translation; }
          set { _translation = value; }
      }
  
      private int _selectedLanguage;
      public int SelectedLanguage
      {
          get
          {
              return _selectedLanguage;
          }
      }
  
      public List&lt;CultureInfo&gt; AvailableLanguages
      {
          get
          {
  
              return (from x in PqsLocalization.AvailableLanguages where x.Name != "en" select x).ToList();
          }
      }
  
      public RelayCommand&lt;int&gt; LanguageChanged { get; private set; }
  
  
      private void LanguageChangedExecute(int lang)
      {
          _selectedLanguage = lang;
          RaisePropertyChanged("SelectedLanguage");
          RaisePropertyChanged("SelectedTranslation");
      }
  </code></pre>