# diagram-annotations

> Diagram displays connected nodes and connectors with annotations that label diagram elements.

**Framework:** maui  **Component:** Diagram  **Variant:** annotations

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/maui/diagram-annotations.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Maui.Diagram
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/diagram-annotations/Diagram.xaml

```xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:diagram="clr-namespace:Syncfusion.Maui.Diagram;assembly=Syncfusion.Maui.Diagram"
             xmlns:editors="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"
             xmlns:conv="clr-namespace:MAUI.Controls.Diagram.Converters"
             x:Class="MAUI.Controls.Diagram.Annotations.AnnotationsView">

    <ContentPage.Resources>
        <conv:ActiveStateToColorConverter x:Key="AlignmentToColor" />
    </ContentPage.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <Grid x:Name="grid" Grid.Column="0">
            <!-- Diagram Control -->
            <diagram:SfDiagram x:Name="Diagram" Nodes="{Binding Nodes}" Connectors="{Binding Connectors}"
                               Grid.Row="0"
                               BackgroundColor="#FAFAFA"
                               HorizontalOptions="Fill"
                               VerticalOptions="Fill"
                               Created="OnCreated" />
        </Grid>

        <ContentView Grid.Column="1">
            <ScrollView Padding="0, 0, 5, 0">
                <StackLayout Orientation="Vertical">
                    <!-- Horizontal Alignment -->
                    <Label Text="Alignment"
                           Margin="0,15,0,8"
                           FontSize="14"
                           FontAttributes="Bold"/>

                    <Grid x:Name="alignmentGrid" ColumnSpacing="5" RowSpacing="5" Margin="0,0,0,15">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Text="TL"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="TopLeft"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=TopLeft}" />
                        <Button Grid.Row="0" Grid.Column="1" Text="Top"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="TopCenter"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=TopCenter}" />
                        <Button Grid.Row="0" Grid.Column="2" Text="TR"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="TopRight"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=TopRight}" />

                        <Button Grid.Row="1" Grid.Column="0" Text="Left"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="Left"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=Left}" />
                        <Button Grid.Row="1" Grid.Column="1" Text="Center"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="Center"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=Center}" />
                        <Button Grid.Row="1" Grid.Column="2" Text="Right"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="Right"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=Right}" />

                        <Button Grid.Row="2" Grid.Column="0" Text="BL"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="BottomLeft"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=BottomLeft}" />
                        <Button Grid.Row="2" Grid.Column="1" Text="Bottom"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="BottomCenter"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=BottomCenter}" />
                        <Button Grid.Row="2" Grid.Column="2" Text="BR"
                                Command="{Binding SetAlignmentCommand}" CommandParameter="BottomRight"
                                BackgroundColor="{Binding SelectedAlignment, Converter={StaticResource AlignmentToColor}, ConverterParameter=BottomRight}" />
                    </Grid>

                    <!-- Appearance Section -->
                    <Label Text="Appearance"
                           Margin="0,15,0,8"
                           FontSize="14"
                           FontAttributes="Bold"/>

                    <Grid x:Name="boldGrid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button Text="B" Command="{Binding ToggleBoldCommand}" Margin="0,0,5,0"
                                BackgroundColor="{Binding IsBold, Converter={StaticResource AlignmentToColor}, ConverterParameter=True}" />
                        <Button Text="I" Grid.Column="1" Command="{Binding ToggleItalicCommand}" Margin="5,0,0,0"
                                BackgroundColor="{Binding IsItalic, Converter={StaticResource AlignmentToColor}, ConverterParameter=True}" />
                    </Grid>

                    <!-- Font Size -->
                    <Grid x:Name="fontSizeGrid" Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5*"/>
                            <ColumnDefinition Width="0.5*"/>
                        </Grid.ColumnDefinitions>
                        <Label Text="Font Size"
                               Margin="0,8,0,0"
                               LineBreakMode="WordWrap"
                               FontSize="14"
                               VerticalOptions="Center"
                               HorizontalOptions="Start"/>
                        <editors:SfNumericEntry Value="{Binding FontSize}"
                                                FontSize="12"
                                                Grid.Column="1"
                                                Margin="5,8,0,0"
                                                VerticalOptions="Center"
                                                HorizontalOptions="End"
                                                Minimum="8"
                                                Maximum="32" />
                    </Grid>

                    <!-- Text Color -->
                    <Grid x:Name="textColorGrid" Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5*"/>
                            <ColumnDefinition Width="0.5*"/>
                        </Grid.ColumnDefinitions>
                        <Label Text="Text Color"
                               Margin="0,15,0,0"
                               LineBreakMode="WordWrap"
                               FontSize="14"
                               VerticalOptions="Center"
                               HorizontalOptions="Start"/>
                        <editors:SfComboBox ItemsSource="{Binding TextColors}"
                                            SelectedIndex="{Binding SelectedTextColorIndex, Mode=TwoWay}"
                                            FontSize="12"
                                            Grid.Column="1"
                                            Margin="5,15,0,0"
                                            VerticalOptions="Center"
                                            HorizontalOptions="End"
                                            IsClearButtonVisible="False" />
                    </Grid>

                    <!-- Font Family -->
                    <Grid x:Name="fontFamilyGrid" Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5*"/>
                            <ColumnDefinition Width="0.5*"/>
                        </Grid.ColumnDefinitions>
                        <Label Text="Font Family"
                               Margin="0,15,0,0"
                               LineBreakMode="WordWrap"
                               FontSize="14"
                               VerticalOptions="Center"
                               HorizontalOptions="Start"/>
                        <editors:SfComboBox ItemsSource="{Binding FontFamilies}"
                                            SelectedIndex="{Binding SelectedFontFamilyIndex, Mode=TwoWay}"
                                            FontSize="12"
                                            Grid.Column="1"
                                            Margin="5,15,0,0"
                                            VerticalOptions="Center"
                                            HorizontalOptions="End"
                                            IsClearButtonVisible="False" />
                    </Grid>

                </StackLayout>
            </ScrollView>
        </ContentView>
    </Grid>
</ContentPage>

```

### src/components/diagram-annotations/Diagram.xaml.cs

```cs
using MAUI.Controls.Diagram.AnnotationsViewModel;

namespace MAUI.Controls.Diagram.Annotations;

public partial class AnnotationsView : ContentPage
{
    public AnnotationsView()
	{
        BindingContext = new AnnotationsViewModel.AnnotationsViewModel();
        InitializeComponent();
    }

    public void OnCreated(object? sender, EventArgs e)
    {
        _ = Diagram.FitToPage();
    }
}

```
