Skip to content

Setter.TargetName + ControlTemplate crash #26977

@viktorszekeress

Description

@viktorszekeress

Description

I have a simple ContentPage with VerticalStackLayout. Within that I have a VisualState and a Setter with TargetName to modify a property on a specific Label control. After activating the VisualState, the label text and bg color should change. This works fine as long as I don't set ContentPage.ControlTemplate property.

Once I set ControlTemplate property, I'm getting XamlParseException: Cannot resolve 'TargetLabel' as Setter Target for 'Microsoft.Maui.Controls.VerticalStackLayout'.

The problem doesn't occur if I comment out ControlTemplate[MauiApp5TargetName.zip](https://github.com/user-attachments/files/18331679/MauiApp5TargetName.zip) block.

For me this effectively blocks me from using TargetName anywhere in our app, as we use an implicit style for all pages that sets ControlTemplate property.

Image
Image
Image

Steps to Reproduce

  1. Open attached solution and run the app (tested on Android 34)
  2. Click the Switch
  3. Application crashes on XamlParseException: Cannot resolve 'TargetLabel' as Setter Target for 'Microsoft.Maui.Controls.VerticalStackLayout'.
  4. Comment out MainPage.ControlTemplate property block
  5. Run the app again
  6. No crash this time

Link to public reproduction project repository

MauiApp5TargetName.zip

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 34

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorspartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions