Bindung von GradientStop funktioniert, meldet jedoch Fehler

Der folgende Code bindet einGradientStop zumBackground.Color Eigentum vonTemplatedParent. Alles funktioniert, aber ich erhalte einen Bindungsfehler im Ausgabefenster:

System.Windows.Data Fehler: 2: Das maßgebliche FrameworkElement oder FrameworkContentElement für das Zielelement wurde nicht gefunden. BindingExpression: Path = Background.Color; DataItem = null; Zielelement ist 'GradientStop' (HashCode = 6944299); Zieleigenschaft ist 'Farbe' (Typ 'Farbe')

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
x:Class="WpfBindingTest.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="100" Height="100">
<Window.Resources>
    <ControlTemplate x:Key="GradientTemplate" TargetType="{x:Type ContentControl}">
        <Border BorderThickness="1" BorderBrush="{TemplateBinding Background}">
            <Border.Background>
                <LinearGradientBrush  EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="{Binding Path=Background.Color, 
                        RelativeSource={RelativeSource TemplatedParent}}"  Offset="1"/>
                    <GradientStop Color="White"  Offset="0"/>
                </LinearGradientBrush>
            </Border.Background>
            <ContentPresenter/>
        </Border>
    </ControlTemplate>
</Window.Resources>

<Grid x:Name="LayoutRoot">
    <ContentControl Background="Green" Template="{StaticResource GradientTemplate}" >
        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="X" />
    </ContentControl>
</Grid>
</Window>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage