Back to results for “Controls & Views”
.NET MAUI › Controls & Views

How do you create a reusable custom control in MAUI?

Advanced

Answer

Create a ContentView (XAML + code-behind) exposing BindableProperties for its inputs, or subclass an existing control. Use BindableProperty.Create so consumers can bind and style the control. For fully custom rendering, subclass a control and customize its handler mapper or draw with GraphicsView.
public partial class RatingControl : ContentView
{
    public static readonly BindableProperty ValueProperty =
        BindableProperty.Create(nameof(Value), typeof(int),
            typeof(RatingControl), 0);

    public int Value
    {
        get => (int)GetValue(ValueProperty);
        set => SetValue(ValueProperty, value);
    }
}
Real-world example A team builds a star-rating ContentView once and reuses it in reviews, feedback, and product pages with two-way binding.

Common follow-ups: What is a BindableProperty? | ContentView vs custom handler?