summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-06 08:56:08 +0100
committerGitHub <noreply@github.com>2016-12-06 08:56:08 +0100
commitff1bf0b5ef5ceb9b5b4b65809f91c4c608d26fff (patch)
tree3188b6fd66414745563c1d99af56dd4e6cdd0c79 /Xamarin.Forms.Xaml
parentc612398bd26bdb0e0d92c7edf5bb102657868431 (diff)
downloadxamarin-forms-ff1bf0b5ef5ceb9b5b4b65809f91c4c608d26fff.tar.gz
xamarin-forms-ff1bf0b5ef5ceb9b5b4b65809f91c4c608d26fff.tar.bz2
xamarin-forms-ff1bf0b5ef5ceb9b5b4b65809f91c4c608d26fff.zip
ResourceDictionary fixes (#536)
* [C] avoid leaking RDs, remove reflection call, validate arguments * [C,Xaml] The only way to get merged values are internal
Diffstat (limited to 'Xamarin.Forms.Xaml')
-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
+}