summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs')
-rw-r--r--Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs11
1 files changed, 4 insertions, 7 deletions
diff --git a/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs b/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
index dc80ade2..703fc206 100644
--- a/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
+++ b/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
@@ -29,14 +29,11 @@ namespace Xamarin.Forms.Xaml
var resDict = ve?.Resources ?? p as ResourceDictionary;
if (resDict == null)
continue;
- if (resDict.TryGetValue(Key, out resource))
+ if (resDict.TryGetMergedValue(Key, out resource))
break;
}
- if (resource == null && Application.Current != null && Application.Current.Resources != null &&
- Application.Current.Resources.ContainsKey(Key))
- resource = Application.Current.Resources[Key];
-
- if (resource == null)
+ if (resource == null && (Application.Current == null || Application.Current.Resources == null ||
+ !Application.Current.Resources.TryGetMergedValue(Key, out resource)))
throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
var bp = valueProvider.TargetProperty as BindableProperty;
@@ -59,4 +56,4 @@ namespace Xamarin.Forms.Xaml
return resource;
}
}
-} \ No newline at end of file
+}