From 44e03cc8661e7574ffa252ac439584be598e7f7c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:27:49 +0100 Subject: [PATCH] [C] test for #17776 (#18264) Co-authored-by: Stephane Delcroix --- .../tests/Core.UnitTests/BindingUnitTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Controls/tests/Core.UnitTests/BindingUnitTests.cs b/src/Controls/tests/Core.UnitTests/BindingUnitTests.cs index 7736c98f9b3f..a748014633ea 100644 --- a/src/Controls/tests/Core.UnitTests/BindingUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/BindingUnitTests.cs @@ -2,11 +2,13 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using Microsoft.Maui.Graphics; using Xunit; namespace Microsoft.Maui.Controls.Core.UnitTests @@ -2338,5 +2340,18 @@ public void ManualValueDoesntClearTwoWayBinding() vm.Text = string.Empty; Assert.Equal(string.Empty, entry.Text); } + + [Fact] + //https://github.com/dotnet/maui/issues/17776 + public void DoubleSetBinding() + { + var button = new Button { BackgroundColor = Colors.HotPink }; + + //shouldn't crash + button.BackgroundColor = Colors.Coral; + button.SetBinding(Button.BackgroundColorProperty, new Binding("BackgroundColor", source: this)); + button.BackgroundColor = Colors.Coral; + button.SetBinding(Button.BackgroundColorProperty, new Binding("BackgroundColor", source: this)); + } } } \ No newline at end of file