From dbe03e090aa4957e48d3046378fa54b149abfb87 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 2 Mar 2020 22:10:33 +0100 Subject: [PATCH] Disallow OneTime bindings in setters. I'm not sure what should happen here when the style deactivates and is re-activated. Should the one-time binding trigger again? Or should it only trigger on first activation? Wait and see what the use-case for this is (if any). --- .../Styling/PropertySetterBindingInstance.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs b/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs index 0741d38146..1400bc2ac3 100644 --- a/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs +++ b/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs @@ -34,6 +34,14 @@ namespace Avalonia.Styling _target = target; _styledProperty = property; _binding = binding.Initiate(_target, property); + + if (_binding.Mode == BindingMode.OneTime) + { + // For the moment, we don't support OneTime bindings in setters, because I'm not + // sure what the semantics should be in the case of activation/deactivation. + throw new NotSupportedException("OneTime bindings are not supported in setters."); + } + _inner = new Inner(this); }