This repository demonstrates how to add a context menu to nodes in the Syncfusion Xamarin.Forms TreeView control. The sample shows how to implement right-click (desktop) and long-press (mobile) menus that provide node-specific actions like edit, delete, and custom commands.
<local:SfTreeViewExt x:Name="treeView" ChildPropertyName="SubFiles" NodeSizeMode="Dynamic" NotificationSubscriptionMode="CollectionChange" ItemsSource="{Binding ImageNodeInfo}" AutoExpandMode="AllNodesExpanded">
<local:SfTreeViewExt.ItemTemplate>
<DataTemplate>
<local:CustomGrid x:Name="grid" TreeView="{x:Reference treeView}">
<local:CustomGrid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1" />
</local:CustomGrid.RowDefinitions>
<Grid RowSpacing="0" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Padding="5,5,5,5">
<Image Source="{Binding ImageIcon}" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="35" WidthRequest="35"/>
</Grid>
<Grid Grid.Column="1" RowSpacing="1" Padding="1,0,0,0" VerticalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label LineBreakMode="NoWrap" TextColor="Black" Text="{Binding ItemName}" VerticalTextAlignment="Center"/>
</Grid>
</Grid>
<StackLayout Grid.Row="1" HeightRequest="1"/>
</local:CustomGrid>
</DataTemplate>
</local:SfTreeViewExt.ItemTemplate>
</local:SfTreeViewExt>To run the demo, refer to System Requirements for Xamarin
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.