Frequent custom control and converter problems
Most of the issues that arise when working with custom controls regularly have to do with bindable properties. Often, a small typo or a little oversight might cause your custom control to not react as expected or to display the wrong data.
Troubleshooting bindable properties
On a custom control, there is a lot of ceremony needed to define bindable properties. It’s very easy to make a mistake that is very hard to spot when troubleshooting. Here are a couple of things to look out for:
- The
propertyName
parameter in theCreate
method: Make sure thepropertyName
parameter matches the exact naming of the property:public static readonly BindableProperty IsFavoriteProperty = BindableProperty.Create(nameof(IsFavorite), …); public bool IsFavorite { ... }
As this code sample shows, it is advised to use the
nameof
expression to prevent typos! - The
returnType
parameter...