diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-03-24 14:29:22 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-03-24 14:47:36 +0900 |
commit | 161a8e0f544b44f848d4c68ac9637d3a8b3f2520 (patch) | |
tree | 9a61043f0e27ef4f9855fcc1fc70693b12f10f4f /Xamarin.Forms.Platform.WinRT.Tablet | |
parent | 20daaa5702a27d1a9c7cf9dfacfdfa254ac0e5e3 (diff) | |
download | xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.tar.gz xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.tar.bz2 xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.zip |
Clean sync with 2.3.4-2
Change-Id: I6a7423d2690a1c30f46e0c128d9504a2464f8f0b
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Tablet')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs | 5 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs | 67 |
2 files changed, 40 insertions, 32 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs index 2ac48dda..2cfc2411 100644 --- a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs @@ -144,11 +144,6 @@ namespace Xamarin.Forms.Platform.WinRT return new SizeRequest(result); } - UIElement IVisualElementRenderer.GetNativeElement() - { - return null; - } - public void Dispose() { Dispose(true); diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs index c4485679..64041c00 100644 --- a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs +++ b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs @@ -1,7 +1,7 @@ -using Windows.UI.Text; +using System; +using Windows.UI.Text; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using WStyle = Windows.UI.Xaml.Style; #if WINDOWS_UWP @@ -15,47 +15,60 @@ namespace Xamarin.Forms.Platform.WinRT { public IResourceDictionary GetSystemResources() { - var prototype = new TextBlock(); - - return new ResourceDictionary - { - [Device.Styles.TitleStyleKey] = GetStyle("HeaderTextBlockStyle", prototype), - [Device.Styles.SubtitleStyleKey] = GetStyle("SubheaderTextBlockStyle", prototype), - [Device.Styles.BodyStyleKey] = GetStyle("BodyTextBlockStyle", prototype), - [Device.Styles.CaptionStyleKey] = GetStyle("CaptionTextBlockStyle", prototype), - [Device.Styles.ListItemDetailTextStyleKey] = GetStyle("BodyTextBlockStyle", prototype), + Windows.UI.Xaml.ResourceDictionary windowsResources = Windows.UI.Xaml.Application.Current.Resources; + var resources = new ResourceDictionary(); + resources[Device.Styles.TitleStyleKey] = GetStyle("HeaderTextBlockStyle"); + resources[Device.Styles.SubtitleStyleKey] = GetStyle("SubheaderTextBlockStyle"); + resources[Device.Styles.BodyStyleKey] = GetStyle("BodyTextBlockStyle"); + resources[Device.Styles.CaptionStyleKey] = GetStyle("CaptionTextBlockStyle"); #if WINDOWS_UWP - [Device.Styles.ListItemTextStyleKey] = GetStyle("BaseTextBlockStyle", prototype), + resources[Device.Styles.ListItemTextStyleKey] = GetStyle("BaseTextBlockStyle"); #else - [Device.Styles.ListItemTextStyleKey] = GetStyle("TitleTextBlockStyle", prototype), + resources[Device.Styles.ListItemTextStyleKey] = GetStyle("TitleTextBlockStyle"); #endif - }; + resources[Device.Styles.ListItemDetailTextStyleKey] = GetStyle("BodyTextBlockStyle"); + return resources; } - Style GetStyle(object nativeKey, TextBlock prototype) + Style GetStyle(object nativeKey) { - var style = (WStyle)Windows.UI.Xaml.Application.Current.Resources[nativeKey]; - - prototype.Style = style; + var style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources[nativeKey]; var formsStyle = new Style(typeof(Label)); + foreach (SetterBase b in style.Setters) + { + var setter = b as Windows.UI.Xaml.Setter; + if (setter == null) + continue; - formsStyle.Setters.Add(Label.FontSizeProperty, prototype.FontSize); - formsStyle.Setters.Add(Label.FontFamilyProperty, prototype.FontFamily.Source); - formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(prototype.FontWeight)); - formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode(prototype.TextWrapping)); + // TODO: Need to implement a stealth pass-through for things we don't support + + try + { + if (setter.Property == TextBlock.FontSizeProperty) + formsStyle.Setters.Add(Label.FontSizeProperty, setter.Value); + else if (setter.Property == TextBlock.FontFamilyProperty) + formsStyle.Setters.Add(Label.FontFamilyProperty, setter.Value); + else if (setter.Property == TextBlock.FontWeightProperty) + formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(Convert.ToUInt16(setter.Value))); + else if (setter.Property == TextBlock.TextWrappingProperty) + formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode((TextWrapping)setter.Value)); + } + catch (NotImplementedException) + { + // see https://bugzilla.xamarin.com/show_bug.cgi?id=33135 + // WinRT implementation of Windows.UI.Xaml.Setter.get_Value is not implemented. + } + } return formsStyle; } - static FontAttributes ToAttributes(FontWeight fontWeight) + static FontAttributes ToAttributes(ushort uweight) { - if (fontWeight.Weight == FontWeights.Bold.Weight || fontWeight.Weight == FontWeights.SemiBold.Weight - || fontWeight.Weight == FontWeights.ExtraBold.Weight) - { + if (uweight == FontWeights.Bold.Weight || uweight == FontWeights.SemiBold.Weight || uweight == FontWeights.ExtraBold.Weight) return FontAttributes.Bold; - } return FontAttributes.None; } |