Skip to content

Assigning "{x:Type ImageButton}" instead of "ImageButton" to the TargetType property of a Trigger in an ImageButton style breaks build #18324

@MauiUIui

Description

@MauiUIui

Description

Almost all in the title. So an ImageButton doesn't allow {x:Type ImageButton} to be assigned as a value to the TargetType property in a Trigger of its style. Doing so yields the famous "Object reference not set to an instance of an object." error which prevents the build from completing. It doesn't matter where the trigger is defined (Default Style in Styles.xaml, in the control itself, in the resources of a containing element...)

Steps to Reproduce

  1. Create a MAUI app.
  2. Create an ImageButton
  3. Give it a style in which a trigger is defined and set the TargetType property of that trigger "{x:Type ImageButton}".
  4. Build fails

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

Set the TargetType property to "ImageButton" instead.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions