public void BindingExtensionRelativeSourceTemplatedParentTest() { string text = @" <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' x:Name='root'> <FrameworkElement x:Name='child' Width='{Binding Height, RelativeSource={RelativeSource TemplatedParent}}'/> </ControlTemplate>"; ControlTemplate template = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate; Control control = new Control(); control.Template = template; control.ApplyTemplate(); FrameworkElement child = NameScope.GetTemplateNameScope(control).FindName("child") as FrameworkElement; Assert.AreEqual(control, child.TemplatedParent); control.Height = 100; Assert.AreEqual(100, child.Width); control.ClearValue(FrameworkElement.HeightProperty); child.SetValue(FrameworkElement.WidthProperty, 200.0, BaseValueSource.ParentTemplate); Assert.AreEqual(200, control.Height); }