From 211b014fa3345036fa9e7fcfa501d0f5cd3d22b0 Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sat, 6 Sep 2025 01:54:18 +0530 Subject: [PATCH 1/2] Update the README.md file --- README.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/README.md b/README.md index 4658bed..48c9d06 100644 --- a/README.md +++ b/README.md @@ -1 +1,99 @@ +# highlight-nodes-on-search-treeview-xamarin + +You can highlight the TreeViewNode when searching in Xamarin.Forms SfTreeView. You can also refer to the search nodes in the SfTreeView document + **[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12160/how-to-highlight-nodes-when-searching-in-xamarin-forms-treeview-sftreeview)** + +## Sample + +### XAML +Bind the model property to customise the BackgroundColor of the ItemTemplate. +```xaml + + + + + + + + + + + + + + + + + + +``` + +### Behavior +```csharp +public class Behavior : Behavior +{ + SearchBar SearchBar; + SfTreeView TreeView; + + protected override void OnAttachedTo(ContentPage bindable) + { + SearchBar = bindable.FindByName("searchBar"); + TreeView = bindable.FindByName("treeView"); + + SearchBar.TextChanged += SearchBar_TextChanged; + + base.OnAttachedTo(bindable); + } + + private void SearchBar_TextChanged(object sender, TextChangedEventArgs e) + { + this.TraverseNodes(TreeView.Nodes, e.NewTextValue); + } + + /// + /// Recursively traverse all the nodes in the TreeView and sets the BackgroundColor for the searched nodes. + /// + /// Represents the TreeViewNodes. + /// Represents the search key word. + private void TraverseNodes(TreeViewNodeCollection nodes, string searchText) + { + foreach (var child in nodes) + { + (child.Content as FileManager).NodeColor = (child.Content as FileManager).ItemName.ToLower().StartsWith(searchText.ToLower()) ? Color.Teal : Color.Transparent; + + if (string.IsNullOrEmpty(searchText)) (child.Content as FileManager).NodeColor = Color.Transparent; + + if (child.ChildNodes != null) + { + this.TraverseNodes(child.ChildNodes, searchText); + } + } + } +} +``` + +## 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. + +## Conclusion + +I hope you enjoyed learning about how to highlight nodes on search in Xamarin.Forms TreeView (SfTreeView). + +You can refer to our Xamarin.Forms TreeViewfeature 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you! \ No newline at end of file From 6171a6aa69ade9b43065d3e9396f93a4a7cd28df Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sun, 7 Sep 2025 22:58:59 +0530 Subject: [PATCH 2/2] license correction commit --- README.md | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 48c9d06..57554a6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ You can highlight the TreeViewNode when searching in Xamarin.Forms SfTreeView. You can also refer to the search nodes in the SfTreeView document -**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12160/how-to-highlight-nodes-when-searching-in-xamarin-forms-treeview-sftreeview)** - ## Sample ### XAML @@ -77,23 +75,9 @@ public class Behavior : Behavior ``` ## 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. - -## Conclusion - -I hope you enjoyed learning about how to highlight nodes on search in Xamarin.Forms TreeView (SfTreeView). - -You can refer to our Xamarin.Forms TreeViewfeature 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you! \ No newline at end of file