This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
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) ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows (show other bugs)
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-08-26 09:00 UTC by Neil McAlister
Modified: 2017-01-30 19:55 UTC (History)
5 users (show)

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


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

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}"/>

-or-

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:

  <StackLayout>
    <Label 
      Text="Welcome to Xamarin Forms!"
      VerticalOptions="Center"
      HorizontalOptions="Center" 
    />
    <Label 
      Text="CaptionStyle" 
      Style="{DynamicResource CaptionStyle}"
    />
    <Label
      Text="BodyStyle"
      Style="{DynamicResource BodyStyle}"
    />
    <Label
      Text="ListItemDetailTextStyle"
      Style="{DynamicResource ListItemDetailTextStyle}"
    />
    <Label
      Text="ListItemTextStyle"
      Style="{DynamicResource ListItemTextStyle}"
    />
  </StackLayout>
Comment 2 Samantha Houts 2017-01-30 19:55:13 UTC
Should be fixed in 2.3.5-pre1. Thank you!

Note You need to log in before you can comment on or make changes to this bug.