|
|
|
@ -39,17 +39,11 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
targetType = setter.Property.PropertyType; |
|
|
|
} |
|
|
|
|
|
|
|
// Look upwards though the ambient context for IResourceHosts and IResourceProviders
|
|
|
|
// Look upwards though the ambient context for IResourceNodes
|
|
|
|
// which might be able to give us the resource.
|
|
|
|
foreach (var e in stack.Parents) |
|
|
|
foreach (var parent in stack.Parents) |
|
|
|
{ |
|
|
|
object value; |
|
|
|
|
|
|
|
if (e is IResourceHost host && host.TryGetResource(ResourceKey, out value)) |
|
|
|
{ |
|
|
|
return ColorToBrushConverter.Convert(value, targetType); |
|
|
|
} |
|
|
|
else if (e is IResourceProvider provider && provider.TryGetResource(ResourceKey, out value)) |
|
|
|
if (parent is IResourceNode node && node.TryGetResource(ResourceKey, out var value)) |
|
|
|
{ |
|
|
|
return ColorToBrushConverter.Convert(value, targetType); |
|
|
|
} |
|
|
|
@ -58,7 +52,10 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
if (provideTarget.TargetObject is IControl target && |
|
|
|
provideTarget.TargetProperty is PropertyInfo property) |
|
|
|
{ |
|
|
|
DelayedBinding.Add(target, property, x => GetValue(x, targetType)); |
|
|
|
var localTargetType = targetType; |
|
|
|
var localInstance = this; |
|
|
|
|
|
|
|
DelayedBinding.Add(target, property, x => localInstance.GetValue(x, localTargetType)); |
|
|
|
return AvaloniaProperty.UnsetValue; |
|
|
|
} |
|
|
|
|
|
|
|
|