Skip to content

Commit e9aa87b

Browse files
ES-975464 - Resolve the ReadMe file length issue in this sample repository
1 parent 9526a94 commit e9aa87b

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

README.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
1-
# How to search and highlight item in TreeViewAdv?
2-
This example demonstrates how to search and highlighted the item of TreeViewAdv control in WPF platform.
1+
# How to search and highlight item in TreeViewAdv
2+
3+
This example demonstrates how to search and highlighted the item of `TreeViewAdv` control in WPF platform.
34

45
# About Sample
56

6-
This sample provides the demo on how to search and highlight the text in TreeViewAdv.
7+
This sample provides the demo on how to search and highlight the text in `TreeViewAdv`.
8+
9+
To search and highlight the item in `TreeViewAdv`, Search method has been implemented which is used to compare the search text with model items. Highlighted the matched text in TextBlock inside the `TreeViewItemAdv`.
10+
11+
``` c#
12+
if (mainitem != null && MatchSearchText(model.Header))
13+
{
14+
//Function which is used to apply inline to the TextBlock
15+
ApplyInline(mainitem, false);
16+
}
17+
```
18+
19+
Options like Search, FindPrevious, Find Next, SearchType (Contains, EndsWith, StartsWith options) has been used to match search text using ApplyInline method and apply the SearchBrush for highlighting the search text.
20+
21+
``` c#
22+
if (!string.IsNullOrEmpty(tempSearchText))
23+
{
24+
if (this.SearchType == SearchType.StartsWith)
25+
{
26+
if (!(bool)CaseSensitiveSearchCheckBox.IsChecked)
27+
regex = new Regex("^(" + tempSearchText + ")", RegexOptions.IgnoreCase);
28+
else
29+
regex = new Regex("^(" + tempSearchText + ")", RegexOptions.None);
30+
}
31+
else if (this.SearchType == SearchType.EndsWith)
32+
{
33+
if (!(bool)CaseSensitiveSearchCheckBox.IsChecked)
34+
regex = new Regex("(" + tempSearchText + ")$", RegexOptions.IgnoreCase);
35+
else
36+
regex = new Regex("(" + tempSearchText + ")$", RegexOptions.None);
37+
}
38+
else
39+
{
40+
if (!(bool)CaseSensitiveSearchCheckBox.IsChecked)
41+
regex = new Regex("(" + tempSearchText + ")", RegexOptions.IgnoreCase);
42+
else
43+
regex = new Regex("(" + tempSearchText + ")", RegexOptions.None);
44+
}
45+
}
46+
```

0 commit comments

Comments
 (0)