Xamarin.forms: [Bug] "FormattedText" does not accept custom styles (Label)

Created on 28 Feb 2020  路  3Comments  路  Source: xamarin/Xamarin.Forms

Description

The "FormattedText" property, does not accept to apply custom styles, shows error when compiling.

Steps to Reproduce

  1. Create Xamarin.Forms project
  2. Create custom styles
  3. Use the "Text format" property

Expected Behavior

You should apply the custom style applied.

Actual Behavior

Does not apply the style, and shows error when compiling.

Basic Information

  • Version with issue: Xamarin Forms 4.4.0.991640
  • IDE: Visual Studio Enterprise 2019 Version 16.4.5
  • Nuget Packages: Xamarin.Forms
  • Affected Devices: Emulador

Screenshots

image

image

Bug
image

Workaround

I have solved it, removing styles, and specifying each property that contains my custom style.

image

unverified bug

All 3 comments

Hi, I think the target type is wrong. Try with TargetType={x:Type Span}

It's right there in the error message you've underlined - your style target type is Label, but you are applying the style to a Span.

Change the target type to Span and remove the properties (HorizontalOptions and Margin) which don't exist on Span, and you will see your style applied.

Thank you for the correction!

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hudhud picture Hudhud  路  3Comments

joseluisct picture joseluisct  路  3Comments

xabre picture xabre  路  3Comments

EmilAlipiev picture EmilAlipiev  路  3Comments

Papirosnik picture Papirosnik  路  3Comments