From bb175b7702a9af0a16f3c6101cfeaa7ff74ccc1d Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sat, 6 Sep 2025 02:54:26 +0530 Subject: [PATCH 1/2] Update the README.md file --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1aa242b..45bd656 100644 --- a/README.md +++ b/README.md @@ -1 +1,64 @@ -**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12488/how-to-do-conditional-navigation-in-xamarin-forms-treeview-sftreeview)** +# conditional-navigation-treeview-xamarin +This repository demonstrates how to implement conditional navigation in a Syncfusion Xamarin.Forms TreeView. The sample shows how to navigate to different pages or perform specific actions based on which node the user selects in the TreeView. By applying conditions in the selection changed event or command, you can control navigation flow, restrict access, or trigger custom logic dynamically according to your application's requirements. + +## Sample + +### XAML + +Bind the SfTreeView.TapCommand to navigate to another page. By default, the TreeViewNode is the command parameter for the TapCommand. + +```xaml + + + + + ... + + + + +``` + +### View Model + +In the command execution method, skip the navigation for nodes based on TreeViewNode.Level. + +```csharp +public class FileManagerViewModel +{ + public FileManagerViewModel() + { + TreeViewTapCommand = new Command(OnTapped); + } + + public Command TreeViewTapCommand { get; set; } + + private void OnTapped(object obj) + { + var node = obj as Syncfusion.TreeView.Engine.TreeViewNode; + + if (node.Level == 0) return; + + var newPage = new Views.NewPage(); + newPage.BindingContext = node; + App.Current.MainPage.Navigation.PushAsync(newPage); + } +} +``` + +## Requirements to run the demo +Visual Studio 2017 or Visual Studio for Mac. +Xamarin add-ons for Visual Studio (available via the Visual Studio installer). + +## Troubleshooting +### Path too long exception +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. + +## License + +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. \ No newline at end of file From 7004159c0d3308ac5fcda1876012976a0d9f2a29 Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sun, 7 Sep 2025 23:02:20 +0530 Subject: [PATCH 2/2] license correction commit --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 45bd656..d2fbbc4 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,9 @@ public class FileManagerViewModel ``` ## Requirements to run the demo -Visual Studio 2017 or Visual Studio for Mac. -Xamarin add-ons for Visual Studio (available via the Visual Studio installer). + +To run the demo, refer to [System Requirements for Xamarin](https://help.syncfusion.com/xamarin/system-requirements) ## Troubleshooting ### Path too long exception 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. - -## License - -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. \ No newline at end of file