Android, Programming, Xamarin

[SOLVED] The BindableProperty “Triggers” is readonly

TLDR: When setting the Triggers property in XAML, use the actual type of the parent tag, not a supertype.

After recently updating Xamarin Forms from 2.3.2.127 to 2.3.3.175, I started getting an InvalidOperationException: The BindableProperty "Triggers is readonly" inside InitializeComponent.

Unlike many problems, this was quite easy to track down. InitializeComponent errors are generally XAML, and in the page in question there was a single Trigger. In this case the solution was simple. The Trigger was on a custom Button type, but I was setting it specifically using Button.Triggers. Changing it to be the actual type fixed it.

So, I changed it from

<local:MyButton>
  <Button.Triggers>
    <DataTrigger ... />
  </Button.Triggers>
</local:MyButton>

to

<local:MyButton>
  <local:MyButton.Triggers>
    <DataTrigger ... />
  </local:MyButton.Triggers>
</local:MyButton>

I believe the original should be valid (and previously was) but the change is simple enough to not be a big problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s