Browse Source

FIx failing test.

Introduced in a refactoring a few commits ago where I saw code that
looked wrong. It wasn't wrong, it's just the mechanism is a little
unintuitive. Added a comment explaining the reasoning.
pull/691/head
Steven Kirk 10 years ago
parent
commit
ecfe572465
  1. 8
      src/Markup/Avalonia.Markup.Xaml/Data/Binding.cs

8
src/Markup/Avalonia.Markup.Xaml/Data/Binding.cs

@ -274,7 +274,13 @@ namespace Avalonia.Markup.Xaml.Data
private IObservable<object> GetParentDataContext(IAvaloniaObject target)
{
return target.GetObservable(Control.ParentProperty)
// The DataContext is based on the visual parent and not the logical parent: this may
// seem unintuitive considering the fact that property inheritance works on the logical
// tree, but consider a ContentControl with a ContentPresenter. The ContentControl's
// Content property is bound to a value which becomes the ContentPresenter's
// DataContext - it is from this that the child hosted by the ContentPresenter needs to
// inherit its DataContext.
return target.GetObservable(Visual.VisualParentProperty)
.Select(x =>
{
return (x as IAvaloniaObject)?.GetObservable(Control.DataContextProperty) ??

Loading…
Cancel
Save