[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.