Two-way binding not working in ContentControl bound to generic value
<p>I am trying to build a user control which allows the editing of items in a list.
First I will show you the code I have and below the code I will explain my problem. If you want to reproduce the issue you can create a new project and copy all the code into it. I will include every class needed.</p>

<p>The code of the list the user control will be bound to:</p>

<pre><code>using System.Collections.Generic;

    namespace TestApplicationWPF
    {
      public class SettingList : List&lt;ISetting&gt;
      {
      }
    }
</code></pre>

<p>The interface ISetting:</p>

<pre><code>namespace TestApplicationWPF
{
  public class ISetting
  {
    string Name { get; set; }
  }
}
</code></pre>

<p>And the generic objects I write into the list:</p>

<pre><code>using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace TestApplicationWPF
{
  public class Setting&lt;T&gt; : ISetting, INotifyPropertyChanged
  {
    public string Name { get; set; }

    private T value;

    public T Value
    {
      get
      {
        return value;
      }
      set
      {
        this.value = value;
        OnPropertyChanged();
      }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
  }
}
</code></pre>

<p>Now the goal for the user control is to bind to an instance of SettingList and allow the user to edit the "Value"-Property of every "Setting"-instance in the list. For that the user control displays a specific control depending on the type of T in Setting. For example a String is shown in a Textbox and a DateTime-Value will be shown in a DatePicker.</p>

<p>The code for the user-control looks like this:</p>

<pre><code>&lt;UserControl x:Class="TestApplicationWPF.SettingEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:TestApplicationWPF"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"&gt;
  &lt;UserControl.Resources&gt;
    &lt;local:TypeOfConverter x:Key="TypeOfConverter" /&gt;
    &lt;Style x:Key="TypedValueStyle" TargetType="{x:Type ContentControl}"&gt;
      &lt;Setter Property="Width" Value="200" /&gt;
      &lt;Setter Property="ContentTemplate"&gt;
        &lt;Setter.Value&gt;
          &lt;DataTemplate&gt;
            &lt;TextBox Text="{Binding Path=.}" IsReadOnly="true" Background="LightGray"/&gt;
          &lt;/DataTemplate&gt;
        &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Style.Triggers&gt;
        &lt;DataTrigger Binding="{Binding Converter={StaticResource TypeOfConverter},Path=Value}" 
                     Value="String"&gt;
          &lt;Setter Property="ContentTemplate"&gt;
            &lt;Setter.Value&gt;
              &lt;DataTemplate&gt;
                &lt;TextBox Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Mode=TwoWay}"                  
                         HorizontalAlignment="Stretch"/&gt;
              &lt;/DataTemplate&gt;
            &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
        &lt;/DataTrigger&gt;
      &lt;/Style.Triggers&gt;
    &lt;/Style&gt;
  &lt;/UserControl.Resources&gt;
  &lt;Grid&gt;
    &lt;Grid.RowDefinitions&gt;
      &lt;RowDefinition Height="80*"/&gt;
      &lt;RowDefinition Height="20*"/&gt;
      &lt;RowDefinition Height="20*"/&gt;
    &lt;/Grid.RowDefinitions&gt;
    &lt;ListView Name="LvPluginSettings" 
              ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:SettingEditor}}, Path=Settings, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
              Grid.Row="0"&gt;
      &lt;ListView.View&gt;
        &lt;GridView&gt;
          &lt;GridViewColumn Header="Name" Width="100"&gt;
            &lt;GridViewColumn.CellTemplate&gt;
              &lt;DataTemplate&gt;
                &lt;Label Content="{Binding Path=Name}"/&gt;
              &lt;/DataTemplate&gt;
            &lt;/GridViewColumn.CellTemplate&gt;
          &lt;/GridViewColumn&gt;
          &lt;GridViewColumn Header="Value" 
                          Width="Auto"&gt;
            &lt;GridViewColumn.CellTemplate&gt;
              &lt;DataTemplate&gt;
                &lt;ContentControl Content="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TypedValueStyle}" /&gt;
              &lt;/DataTemplate&gt;
            &lt;/GridViewColumn.CellTemplate&gt;
          &lt;/GridViewColumn&gt;
        &lt;/GridView&gt;
      &lt;/ListView.View&gt;
    &lt;/ListView&gt;
    &lt;Button Name ="BtnSetValue" Grid.Row="1" Content="Set the value" Click="BtnSetValue_Click"/&gt;
    &lt;Button Name ="BtnGetValue" Grid.Row="2" Content="What's the value?" Click="BtnGetValue_Click"/&gt;
  &lt;/Grid&gt;
&lt;/UserControl&gt;
</code></pre>

<p>The .cs Code for the user-control:</p>

<pre><code>using System.Windows;
using System.Windows.Controls;

namespace TestApplicationWPF
{
  public partial class SettingEditor : UserControl
  {

    public SettingList Settings
    {
      get { return (SettingList)GetValue(PluginSettingsProperty); }
      set { SetValue(PluginSettingsProperty, value); }
    }

    public static readonly DependencyProperty PluginSettingsProperty = DependencyProperty.Register(
                "Settings",
                typeof(SettingList),
                typeof(SettingEditor),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
    );

    public SettingEditor()
    {
      InitializeComponent();
    }

    private void BtnSetValue_Click(object sender, RoutedEventArgs e)
    {
      ((Setting&lt;string&gt;)Settings[0]).Value = "Different value now.";
    }

    private void BtnGetValue_Click(object sender, RoutedEventArgs e)
    {
      MessageBox.Show(((Setting&lt;string&gt;)Settings[0]).Value);
    }
  }
}
</code></pre>

<p>To determine the type of the "Value"-property of each item in the list I make use of a "TypeOfConverter". The converter looks like this:</p>

<pre><code>using System;
using System.Windows.Data;

namespace TestApplicationWPF
{
  public class TypeOfConverter : IValueConverter
  {
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      return (value == null) ? null : value.GetType().Name;
    }
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}
</code></pre>

<p>And at last to be able to completely reproduce the issue I give you the MainWindow which uses the user control and it's ViewModel:
Window:</p>

<pre><code>&lt;Window x:Class="TestApplicationWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TestApplicationWPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Window.Resources&gt;
    &lt;local:MainWindowViewModel x:Key="MainWindowViewModel" /&gt;
  &lt;/Window.Resources&gt;
    &lt;Grid DataContext="{StaticResource MainWindowViewModel}"&gt;
    &lt;local:SettingEditor Settings="{Binding Path=Settings}" /&gt;
  &lt;/Grid&gt;
&lt;/Window&gt;
</code></pre>

<p>ViewModel:</p>

<pre><code>namespace TestApplicationWPF
{
  public class MainWindowViewModel
  {
    public SettingList Settings { get; set; }

    public MainWindowViewModel()
    {
      Settings = new SettingList();
      Settings.Add(new Setting&lt;string&gt; { Name="Name of setting", Value = "HelloWorld" });
    }

  }
}
</code></pre>

<p>My problem is the binding of the Value-Property of a Setting-Instance. When I start the application it will show me the value perfectly fine. I get a textbox with "HelloWorld" in it. Also when the value changes in the background it will be updated to the textbox.
However when I set the cursor into the textbox, change the text to something else and leave the textbox, it will not be changed in the bound "Value"-Property. Also after I tried to edit the text in the textbox, changes made in the background do not affect the textbox anymore.</p>

<p>I would be deeply grateful if someone could help me with this. Even the smallest hint at what could be wrong would help me a lot.</p>

<p>Greetings,
Sven</p>