diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-03-02 23:28:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-02 23:28:37 +0100 |
commit | d2708bbadd0bf09c2542e354683c0fd1bbc84707 (patch) | |
tree | 6f267d261bbc60cfa9a723a9ade669e061f17aa8 /Xamarin.Forms.Core | |
parent | a03c8f32d20a61a1a553b7db0e2f978c44a4ca84 (diff) | |
download | xamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.tar.gz xamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.tar.bz2 xamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.zip |
[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
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r-- | Xamarin.Forms.Core/MergedStyle.cs | 7 | ||||
-rw-r--r-- | Xamarin.Forms.Core/ResourcesExtensions.cs | 5 |
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; } |