summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-03-02 23:36:25 +0100
committerJason Smith <jason.smith@xamarin.com>2017-03-02 14:36:25 -0800
commitdbe0d4945da400a5b00599155d22cda78754294a (patch)
treeab325fe3a233b0d00011e2cd4b2627d860d27ca2 /Xamarin.Forms.Core
parentc57f859745aeef7965e03639fc016ee0c7a8a218 (diff)
downloadxamarin-forms-dbe0d4945da400a5b00599155d22cda78754294a.tar.gz
xamarin-forms-dbe0d4945da400a5b00599155d22cda78754294a.tar.bz2
xamarin-forms-dbe0d4945da400a5b00599155d22cda78754294a.zip
Backport #793 (#796)
* [Xaml] Fallback to App.Current for DynResources (Previewer) (#793) * [Xaml] Fallback to App.Current for DynResources (Previewer) * [C] avoid NRE and ensure setting the style * remove files committed by accident
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/MergedStyle.cs7
-rw-r--r--Xamarin.Forms.Core/ResourcesExtensions.cs5
2 files changed, 8 insertions, 4 deletions
diff --git a/Xamarin.Forms.Core/MergedStyle.cs b/Xamarin.Forms.Core/MergedStyle.cs
index 59a1dea6..941ebbd8 100644
--- a/Xamarin.Forms.Core/MergedStyle.cs
+++ b/Xamarin.Forms.Core/MergedStyle.cs
@@ -125,12 +125,11 @@ namespace Xamarin.Forms
void RegisterImplicitStyles()
{
Type type = TargetType;
- while (true)
- {
+ while (true) {
BindableProperty implicitStyleProperty = BindableProperty.Create("ImplicitStyle", typeof(Style), typeof(VisualElement), default(Style),
- propertyChanged: (bindable, oldvalue, newvalue) => ((VisualElement)bindable)._mergedStyle.OnImplicitStyleChanged());
- Target.SetDynamicResource(implicitStyleProperty, type.FullName);
+ propertyChanged: (bindable, oldvalue, newvalue) => OnImplicitStyleChanged());
_implicitStyles.Add(implicitStyleProperty);
+ Target.SetDynamicResource(implicitStyleProperty, type.FullName);
type = type.GetTypeInfo().BaseType;
if (s_stopAtTypes.Contains(type))
return;
diff --git a/Xamarin.Forms.Core/ResourcesExtensions.cs b/Xamarin.Forms.Core/ResourcesExtensions.cs
index 8930abf2..7d2f8d0f 100644
--- a/Xamarin.Forms.Core/ResourcesExtensions.cs
+++ b/Xamarin.Forms.Core/ResourcesExtensions.cs
@@ -55,6 +55,11 @@ namespace Xamarin.Forms
return true;
element = element.Parent;
}
+
+ //Fallback for the XF previewer
+ if (Application.Current != null && Application.Current.Resources != null && Application.Current.Resources.TryGetValue(key, out value))
+ return true;
+
value = null;
return false;
}