From 4a92d9b3b1529b6bee6720e6ceac74bb8fbad222 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 4 Nov 2024 17:34:26 +0100 Subject: [PATCH 1/2] Add failing test for TemplateBinding inside custom control template --- .../Xaml/ControlTemplateTests.cs | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlTemplateTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlTemplateTests.cs index b2c697cbad2..af291b6626d 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlTemplateTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlTemplateTests.cs @@ -6,10 +6,12 @@ using Avalonia.Controls.Metadata; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; +using Avalonia.Controls.Templates; using Avalonia.Data; using Avalonia.Diagnostics; using Avalonia.Markup.Xaml.Templates; using Avalonia.Media; +using Avalonia.Metadata; using Avalonia.UnitTests; using Avalonia.VisualTree; using Xunit; @@ -437,13 +439,47 @@ public void ControlTemplate_Outputs_Error_When_Missing_TemplatePart_Nested_ItemT Assert.Equal(RuntimeXamlDiagnosticSeverity.Info, warning.Severity); Assert.Contains("'PART_MainContentBorder'", warning.Title); } + +#nullable enable + + [Fact] + public void Custom_ControlTemplate_Allows_TemplateBindings() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var window = (Window)AvaloniaRuntimeXamlLoader.Load( + """ + + + + """); + var button = Assert.IsType