summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-02-13 08:08:21 (GMT)
committerGitHub <noreply@github.com>2017-02-13 08:08:21 (GMT)
commitd108dfe17652d3f6a18bf76d0b7f955b74244998 (patch)
tree08e09945ac6fb1caf1933a84ae775f0cc6be1ff9 /Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
parent7ffc19b2b5b70f32a8d865573824da29249ebf7a (diff)
downloadxamarin-forms-d108dfe17652d3f6a18bf76d0b7f955b74244998.zip
xamarin-forms-d108dfe17652d3f6a18bf76d0b7f955b74244998.tar.gz
xamarin-forms-d108dfe17652d3f6a18bf76d0b7f955b74244998.tar.bz2
[XamlC] compiled TypeExtension (#739)
Diffstat (limited to 'Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs')
-rw-r--r--Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs15
1 files changed, 11 insertions, 4 deletions
diff --git a/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs b/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
index 34f1c56..fc00d30 100644
--- a/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
+++ b/Xamarin.Forms.Xaml/MarkupExtensions/StaticResourceExtension.cs
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
+using System.Xml;
namespace Xamarin.Forms.Xaml
{
@@ -32,9 +33,7 @@ namespace Xamarin.Forms.Xaml
if (resDict.TryGetMergedValue(Key, out resource))
break;
}
- 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);
+ resource = resource ?? GetApplicationLevelResource(Key, xmlLineInfo);
var bp = valueProvider.TargetProperty as BindableProperty;
var pi = valueProvider.TargetProperty as PropertyInfo;
@@ -55,5 +54,13 @@ namespace Xamarin.Forms.Xaml
return resource;
}
+
+ internal object GetApplicationLevelResource(string key, IXmlLineInfo xmlLineInfo)
+ {
+ object resource;
+ if (Application.Current == null || Application.Current.Resources == null || !Application.Current.Resources.TryGetMergedValue(Key, out resource))
+ throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
+ return resource;
+ }
}
-}
+} \ No newline at end of file