Creating a Button with Multiple Components

Nathan Sokalski 4,121 Reputation points

I want to create a Button that is made up of multiple parts. I am very new to Xamarin.Forms & Android, but what I have found makes it sound like a CustomRenderer is what I should be using. However, from what I have seen in the examples I could find, the CustomRenderer only lets you change properties of a Button. I am looking for something more like the Content property or Template property & ControlTemplate that existed in UWP (I have a large background in UWP & am working on converting my apps to Xamarin.Forms). These let you use any elements you wanted for the visual component of the control. I want the same properties & events as a regular Button, but I need to have multiple elements in the visual part of the Button (such as an image, multiple text elements, shapes, etc.). How do I do this? Thanks.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,312 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Morgan SOULLEZ 1 Reputation point

    Look at the TemplatedView, with that ancestor you can create a fully customizable controls.
    There is an actual Pull Request on the Xamarin.CommunityToolkit for adding the control that you need. You can be inspired by this one to create your own or wait for this PR to be merged.

    0 comments No comments