Bug 43783 - [WP8.1] Most Device Styles do not render correctly in Windows Phone 8.1 (RT) applications
Summary: [WP8.1] Most Device Styles do not render correctly in Windows Phone 8.1 (RT) ...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-08-26 09:00 UTC by Neil McAlister
Modified: 2017-01-30 19:55 UTC (History)
5 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Screenshot of text rendering weirdness (102.40 KB, image/png)
2016-08-26 09:00 UTC, Neil McAlister

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Neil McAlister 2016-08-26 09:00:08 UTC
Created attachment 17218 [details]
Screenshot of text rendering weirdness

When running a Xamarin.Forms Windows Phone 8.1 RT project, the following Device Styles do not render correctly.
 - ListItemTextStyle
 - ListItemDetailTextStyle
 - CaptionStyle
 - BodyStyle

All Labels using these styles appears as very small, and is unstyled.

This has further ramifications for default unstyled Label, as it appears to use the BodyStyle.

To reproduce:
Create a new Xamarin.Forms (PCL or Shared project) solution with a Windows Phone 8.1 (RT) project. Add Labels to any page using any of the above-mentioned styles, like so:

<Label Text="I am some text." Style="{DynamicResource CaptionStyle}"/>


Label label = new Label();
label.Text = "I am some text.";
label.Style = Xamarin.Forms.Device.Styles.CaptionStyle;

Actual Results:
Using any of these styles, or a default, unstyled Label results in small, unstyled text. See the attached screenshot for a comparison of how it looks in Xamarin.Forms.iOS, Xamarin.Forms.WindowsPhone and a native Windows Phone application.

Expected Results:
The device styles render as they would on the native platform. Judging from the Xamarin.Forms source code, the mapping should be as follows:

Xamarin.Forms -> Native Style
 - ListItemTextStyle -> ListViewItemTextBlockStyle
 - ListItemDetailTextStyle -> ListViewItemContentTextBlockStyle
 - CaptionStyle -> BodyTextBlockStyle
 - BodyStyle -> BodyTextBlockStyle

Build date & Hardware:
August 26, 2016, on Windows 10, Anniversary Update.

Target platforms:
Windows Phone 8.1, and Windows 10 Mobile.

A potential place to start:
I spent some time digging around in the Xamarin.Forms source code, and I suspect the culprit is in fact in Xamarin.Forms.Platform.WinRT.WindowsPhoneResourcesProvider. When it's pulling the Setters out of the default Styles, it seems to fail when attempting to resolve ThemeResources. Instead of handing an actual, concrete value to the Xamarin.Forms.Style, it hands over a BindingExpressionBase. When Xamarin.Forms then attempts to apply that BindingExpressionBase to (for example) the Label's FontSize proprety, the cast fails, and the style's Setter silently fails.

I'm not sure how that might be solved, as it doesn't look like it's possible to actually _do_ anything with BindingExpressionBase, nor to get the key of the ThemeResource the Setter's Value is pointing at. Hopefully it's a place to start though.
Comment 1 Chris King 2016-10-05 18:35:20 UTC
Confirmed. The following all render the same on WP8.1:

      Text="Welcome to Xamarin Forms!"
      Style="{DynamicResource CaptionStyle}"
      Style="{DynamicResource BodyStyle}"
      Style="{DynamicResource ListItemDetailTextStyle}"
      Style="{DynamicResource ListItemTextStyle}"
Comment 2 Samantha Houts [MSFT] 2017-01-30 19:55:13 UTC
Should be fixed in 2.3.5-pre1. Thank you!