Skip to content

Commit

Permalink
Merge pull request #13943 from Youssef1313/issues/13517
Browse files Browse the repository at this point in the history
fix(XamlReader): Properly support TemplateBinding of attached properties
  • Loading branch information
jeromelaban authored Oct 12, 2023
2 parents 447b1eb + c187ba5 commit 150557a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,10 @@ public void When_TemplateBinding_AttachedProperty()
var sut = setup.FindFirstDescendant<ScrollViewer>(x => x.Name == "SUT");
var expr = sut.GetBindingExpression(ScrollViewer.HorizontalScrollModeProperty);

Assert.AreEqual(expr.ParentBinding.Path.Path, "ScrollViewer.HorizontalScrollMode");

// disabled due to https://github.com/unoplatform/uno/issues/13121#issuecomment-1666666795 (point 2)
//Assert.AreEqual(ScrollMode.Disabled, sut.HorizontalScrollMode);
//ScrollViewer.SetHorizontalScrollMode(setup, ScrollMode.Enabled);
//Assert.AreEqual(ScrollMode.Enabled, sut.HorizontalScrollMode);
Assert.AreEqual(expr.ParentBinding.Path.Path, "(Windows.UI.Xaml.Controls:ScrollViewer.HorizontalScrollMode)");
Assert.AreEqual(ScrollMode.Disabled, sut.HorizontalScrollMode);
ScrollViewer.SetHorizontalScrollMode(setup, ScrollMode.Enabled);
Assert.AreEqual(ScrollMode.Enabled, sut.HorizontalScrollMode);
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,13 @@ private Binding BuildBindingExpression(object? instance, object? rootInstance, X
{
case "_PositionalParameters":
case nameof(Binding.Path):
binding.Path = RewriteAttachedPropertyPath(bindingProperty.Value?.ToString());
var path = bindingProperty.Value?.ToString();
if (templateBindingNode is not null && TypeResolver.IsAttachedProperty(member))
{
path = $"({path})";
}

binding.Path = RewriteAttachedPropertyPath(path);
break;

case nameof(Binding.ElementName):
Expand Down

0 comments on commit 150557a

Please sign in to comment.