diff --git a/src/Avalonia.Base/Data/BindingValue.cs b/src/Avalonia.Base/Data/BindingValue.cs
index 595295bf36..6f0f5696fd 100644
--- a/src/Avalonia.Base/Data/BindingValue.cs
+++ b/src/Avalonia.Base/Data/BindingValue.cs
@@ -237,6 +237,19 @@ namespace Avalonia.Data
/// The untyped value.
/// The typed binding value.
public static BindingValue FromUntyped(object? value)
+ {
+ return FromUntyped(value, typeof(T));
+ }
+
+ ///
+ /// Creates a from an object, handling the special values
+ /// , and
+ /// .
+ ///
+ /// The untyped value.
+ /// The runtime target type.
+ /// The typed binding value.
+ public static BindingValue FromUntyped(object? value, Type targetType)
{
if (value == AvaloniaProperty.UnsetValue)
return Unset;
@@ -265,13 +278,13 @@ namespace Avalonia.Data
if ((type & BindingValueType.HasValue) != 0)
{
- if (TypeUtilities.TryConvertImplicit(typeof(T), value, out var typed))
+ if (TypeUtilities.TryConvertImplicit(targetType, value, out var typed))
v = (T)typed!;
else
{
var e = new InvalidCastException(
$"Unable to convert object '{value ?? "(null)"}' " +
- $"of type '{value?.GetType()}' to type '{typeof(T)}'.");
+ $"of type '{value?.GetType()}' to type '{targetType}'.");
if (error is null)
error = e;
diff --git a/src/Avalonia.Base/PropertyStore/BindingEntry.cs b/src/Avalonia.Base/PropertyStore/BindingEntry.cs
deleted file mode 100644
index 45040bd245..0000000000
--- a/src/Avalonia.Base/PropertyStore/BindingEntry.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using System;
-using System.Reactive.Disposables;
-using Avalonia.Data;
-
-namespace Avalonia.PropertyStore
-{
- internal class BindingEntry : IValueEntry,
- IObserver