How to Create a Custom Color Palette in the .NET MAUI Color Picker?
This article demonstrates how to create a custom color palette using the Syncfusion® .NET MAUI Color Picker in a .NET MAUI application.
In this example, the SfColorPicker is configured to display a custom palette of five vibrant colors arranged in a grid with 5 columns and 2 rows.
XAML:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:inputs="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"
xmlns:local="clr-namespace:ColorPickerSample"
x:Class="ColorPickerSample.MainPage">
<inputs:SfColorPicker x:Name="colorPicker" ColorMode="Palette"
PaletteColumnCount="7" PaletteRowCount="2"
ShowRecentColors="False"/>
</ContentPage>
C#:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
List<Color> customColors = new List<Color>
{
Colors.Red,
Colors.OrangeRed,
Colors.DeepPink,
Colors.BlueViolet,
Colors.DodgerBlue,
Colors.YellowGreen,
Colors.Green
};
colorPicker.PaletteColors = customColors;
}
}
Output:
Download the complete sample from GitHub.
Conclusion
I hope you enjoyed learning how to create a custom color palette in the .NET MAUI Color Picker (SfColorPicker).
Refer to our .NET MAUI Color Picker feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications.
For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls.
If you have any queries or require clarification, please let us know in the comments section below. You can also contact us through our Support Forums, Direct-Trac, or Feedback Portal. We are always happy to assist you!