How can I help you?
Display View Customization
26 Jun 20254 minutes to read
Selected color customization
Selected color icon
You can customize the selected color icon in the Color Picker using the SelectedColorIcon property.
<inputs:SfColorPicker x:Name="colorPicker">
<inputs:SfColorPicker.SelectedColorIcon>
<FontImageSource FontFamily="MauiMaterialAssets" Glyph="" Color="{Binding Source={x:Reference colorPicker},Path=SelectedColor}"/>
</inputs:SfColorPicker.SelectedColorIcon>
</inputs:SfColorPicker>var fontIcon = new FontImageSource
{
FontFamily = "MauiMaterialAssets",
Glyph = "\ue760",
Color = colorPicker.SelectedColor
};
colorPicker.SelectedColorIcon = fontIcon;
colorPicker.ColorChanged += (s, e) =>
{
fontIcon.Color = e.NewColor;
};![]()
Selected color template
To customize the appearance of the selected color, use the SelectedColorTemplate property to define a custom template.
<inputs:SfColorPicker x:Name="colorPicker">
<inputs:SfColorPicker.SelectedColorTemplate>
<DataTemplate>
<VerticalStackLayout WidthRequest="70" Background="White">
<Label Text="A" HorizontalOptions="Center" TextColor="Black"/>
<BoxView HeightRequest="5" WidthRequest="30" Background="{Binding Source={x:Reference colorPicker},Path=SelectedColor}" />
</VerticalStackLayout>
</DataTemplate>
</inputs:SfColorPicker.SelectedColorTemplate>
</inputs:SfColorPicker>colorPicker.SelectedColorTemplate = new DataTemplate(() =>
{
var label = new Label
{
Text = "A",
HorizontalOptions = LayoutOptions.Center,
TextColor = Colors.Black
};
// Create the box view and bind its Background to colorPicker.SelectedColor
var boxView = new BoxView
{
HeightRequest = 5,
WidthRequest = 30
};
boxView.SetBinding(BoxView.BackgroundProperty, new Binding
{
Source = colorPicker,
Path = "SelectedColor",
Mode = BindingMode.OneWay
});
// Create the layout
var stackLayout = new VerticalStackLayout
{
WidthRequest = 70,
BackgroundColor = Colors.White,
Children = { label, boxView }
};
return stackLayout;
});
Content = colorPicker;
Drop-down icon
The drop-down icon of the Color Picker can be customized using the DropDownButtonTemplate property.
<inputs:SfColorPicker x:Name="colorPicker">
<inputs:SfColorPicker.DropDownButtonTemplate>
<DataTemplate>
<Label Text="" FontFamily="MauiMaterialAssets" FontSize="14" TextColor="Black" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" />
</DataTemplate>
</inputs:SfColorPicker.DropDownButtonTemplate>
</inputs:SfColorPicker>var dropDownTemplate = new DataTemplate(() =>
{
return new Label
{
Text = "\ue705",
FontFamily = "MauiMaterialAssets",
TextColor = Colors.Black,
FontSize = 14,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center
};
});
SfColorPicker colorPicker = new SfColorPicker
{
DropDownButtonTemplate = dropDownTemplate
};
Content = colorPicker;