This sample demonstrates how to implement real-time preview in a drawing app using the MAUI Color Picker in a .NET MAUI application.
<Grid RowDefinitions="140,*">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="15">
<Border Stroke="Gray">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<Grid ColumnDefinitions="45,Auto" RowDefinitions="Auto,Auto,Auto"
ColumnSpacing="50" Margin="15">
<!--Pen-->
<VerticalStackLayout Grid.Column="0" Grid.Row="0" HorizontalOptions="Center">
<Label Text="" FontFamily="MauiMaterialAssets" FontSize="20"
HorizontalOptions="Center" VerticalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="PenGestureRecognizerTapped"/>
</Label.GestureRecognizers>
</Label>
<Label Text="Pen" HorizontalOptions="Center"/>
</VerticalStackLayout>
<!--Brush-->
<VerticalStackLayout Grid.Column="1" Grid.Row="0" HorizontalOptions="Center">
<Label Text="" FontFamily="MauiMaterialAssets" FontSize="20"
HorizontalOptions="Center" VerticalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="BrushGestureRecognizerTapped"/>
</Label.GestureRecognizers>
</Label>
<Label Text="Brush" HorizontalOptions="Center"/>
</VerticalStackLayout>
<!--Reset-->
<VerticalStackLayout Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
HorizontalOptions="Center">
<Label Text="" FontFamily="MauiMaterialAssets" FontSize="20"
HorizontalOptions="Center" VerticalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="ResetTapped"/>
</Label.GestureRecognizers>
</Label>
<Label Text="Reset" HorizontalOptions="Center"/>
</VerticalStackLayout>
</Grid>
</Border>
<!--Color Picker-->
<Border Stroke="Gray">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<VerticalStackLayout Margin="5,10,5,5">
<inputs:SfColorPicker x:Name="colorPicker" ColorMode="Palette"
PaletteRowCount="2" PaletteRowSpacing="5"
PaletteColumnSpacing="5" ShowRecentColors="False"
IsColorModeSwitcherVisible="False" IsInline="True" />
</VerticalStackLayout>
</Border>
</StackLayout>
<!--Drawing Pad-->
<Border Grid.Row="1" StrokeThickness="1" Stroke="Gray" Margin="15,0,15,15">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10"/>
</Border.StrokeShape>
<signaturePad:SfSignaturePad x:Name="signaturePad" Background ="Transparent"
StrokeColor="{Binding Source={x:Reference colorPicker}, Path=SelectedColor}"/>
</Border>
</Grid>To run the demo, refer to System Requirements for .NET MAUI
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.
Syncfusion has no liability for any damage or consequence that may arise from using or viewing the samples. The samples are for demonstrative purposes. If you choose to use or access the samples, you agree to not hold Syncfusion liable, in any form, for any damage related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion's samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion's samples