Articles in this section
Category / Section

How to trigger ItemHolding event using mouse hold in the Xamarin.Forms TreeView?

1 min read

The Xamarin.Forms TreeView allows you to trigger the ItemHolding event using mouse hold in the UWP platform by using the HoldGesture attached property.

XAML

Set Hold and HoldWithMouse to  HoldGesture to trigger the ItemHolding event when holding the item with the mouse.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:TreeViewXamarin"
             xmlns:syncfusion="clr-namespace:Syncfusion.XForms.TreeView;assembly=Syncfusion.SfTreeView.XForms"
             xmlns:windowsspecific="clr-namespace:Syncfusion.XForms.TreeView.PlatformConfiguration.WindowsSpecific;assembly=Syncfusion.SfTreeView.XForms"
             x:Class="TreeViewXamarin.MainPage">
 
    <ContentPage.BindingContext>
        <local:FileManagerViewModel x:Name="viewModel"/>
    </ContentPage.BindingContext>
 
    <StackLayout>
        <syncfusion:SfTreeView x:Name="treeView" windowsspecific:TreeView.HoldGesture="Hold,HoldWithMouse" ChildPropertyName="SubFiles" ItemTemplateContextType="Node" AutoExpandMode="AllNodesExpanded" ItemsSource="{Binding ImageNodeInfo}">
            <syncfusion:SfTreeView.Behaviors>
                <local:TreeViewBehavior/>
            </syncfusion:SfTreeView.Behaviors>
            <syncfusion:SfTreeView.ItemTemplate>
                <DataTemplate>
                    <Grid x:Name="grid" RowSpacing="0" >
                        ...
                    </Grid>
                </DataTemplate>
            </syncfusion:SfTreeView.ItemTemplate>
        </syncfusion:SfTreeView>
    </StackLayout>
</ContentPage>

View sample in GitHub


Conclusion

I hope you enjoyed learning about how to trigger ItemHolding event using mouse hold in the Xamarin.Forms TreeView (SfTreeView).

You can refer to our Xamarin.Forms TreeView feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied