Browse Source
Merge pull request #8680 from AvaloniaUI/fixes/8678-devtools-hackfix
Hackfix to make DevTools work again.
pull/8686/head
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
18 additions and
0 deletions
-
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs
|
|
|
@ -39,6 +39,8 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
targetType = setter.Property.PropertyType; |
|
|
|
} |
|
|
|
|
|
|
|
var previousWasControlTheme = false; |
|
|
|
|
|
|
|
// Look upwards though the ambient context for IResourceNodes
|
|
|
|
// which might be able to give us the resource.
|
|
|
|
foreach (var parent in stack.Parents) |
|
|
|
@ -47,6 +49,21 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
{ |
|
|
|
return ColorToBrushConverter.Convert(value, targetType); |
|
|
|
} |
|
|
|
|
|
|
|
// HACK: Temporary fix for #8678. Hard-coded to only work for the DevTools main
|
|
|
|
// window as we don't want 3rd parties to start relying on this hack.
|
|
|
|
//
|
|
|
|
// We need to implement compile-time merging of resource dictionaries and this
|
|
|
|
// hack can be removed.
|
|
|
|
if (previousWasControlTheme && |
|
|
|
parent is ResourceDictionary hack && |
|
|
|
hack.Owner?.GetType().FullName == "Avalonia.Diagnostics.Views.MainWindow" && |
|
|
|
hack.Owner.TryGetResource(ResourceKey, out value)) |
|
|
|
{ |
|
|
|
return ColorToBrushConverter.Convert(value, targetType); |
|
|
|
} |
|
|
|
|
|
|
|
previousWasControlTheme = parent is ControlTheme; |
|
|
|
} |
|
|
|
|
|
|
|
if (provideTarget.TargetObject is IControl target && |
|
|
|
@ -69,3 +86,4 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|