Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

UWP: InvalidCastException on a Span with a style set via a dynamic resource #3979

@davidbritch

Description

@davidbritch

Description

The following XAML causes an InvalidCastException(unable to cast object of type Span to Label) on UWP:

        <Label>
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" />
                    <Span Text="default, " Style="{DynamicResource BodyStyle}">
                        <Span.GestureRecognizers>
                            <TapGestureRecognizer Command="{Binding TapCommand}" />
                        </Span.GestureRecognizers>
                    </Span>
                    <Span Text="italic small." FontAttributes="Italic" FontSize="Small" />
                </FormattedString>
            </Label.FormattedText>
        </Label>

The issue is setting the Style on the second Span. After removing the style the code executes as expected.

Note that there aren't any problems with this code on iOS/Android.

Steps to Reproduce

  1. Run the attached sample.
  2. Browse to the "Label Demo - XAML" page.

Expected Behavior

The "Label Demo - XAML" page displays.

Actual Behavior

An InvalidCastException is thrown (unable to cast object of type Span to Label).

Basic Information

  • Version with issue: 3.2.0.839982 (also 3.3-pre2)
  • IDE: VS2017 15.8.4
  • Platform Target Frameworks:
    • UWP: 10.0.16299.0

Reproduction Link

Text.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions