@@ -19,34 +19,32 @@ The following code sample explains the single item selection in TreeView.
1919
2020``` XML
2121
22- <treeView : SfTreeView x : Name =" treeView"
23- Width =" 400"
24- Height =" 500"
25- AutoExpandMode =" AllNodes"
26- ChildPropertyName =" Childs"
27- IsAnimationEnabled =" True"
28- SelectionMode =" Single"
29- FullRowSelect =" True"
30- ItemsSource =" {Binding Nodes1}" >
31- <treeView : SfTreeView .ItemTemplate>
32- <DataTemplate >
33- <StackPanel Orientation =" Horizontal" >
34- <ContentPresenter Width =" 20"
35- Height =" 20"
36- HorizontalAlignment =" Stretch"
37- VerticalAlignment =" Center"
38- ContentTemplate =" {Binding ImageTemplate}" />
39- <TextBlock
40- Margin =" 5"
41- VerticalAlignment =" Center"
42- Text =" {Binding Header}" />
43- </StackPanel >
44- </DataTemplate >
45- </treeView : SfTreeView .ItemTemplate>
22+ <treeView : SfTreeView x : Name =" treeView"
23+ Width =" 400"
24+ Height =" 500"
25+ AutoExpandMode =" AllNodes"
26+ ChildPropertyName =" Childs"
27+ IsAnimationEnabled =" True"
28+ SelectionMode =" Single"
29+ FullRowSelect =" True"
30+ ItemsSource =" {Binding Nodes1}" >
31+ <treeView : SfTreeView .ItemTemplate>
32+ <DataTemplate >
33+ <StackPanel Orientation =" Horizontal" >
34+ <ContentPresenter Width =" 20"
35+ Height =" 20"
36+ HorizontalAlignment =" Stretch"
37+ VerticalAlignment =" Center"
38+ ContentTemplate =" {Binding ImageTemplate}" />
39+ <TextBlock Margin =" 5"
40+ VerticalAlignment =" Center"
41+ Text =" {Binding Header}" />
42+ </StackPanel >
43+ </DataTemplate >
44+ </treeView : SfTreeView .ItemTemplate>
4645</treeView : SfTreeView >
4746
4847```
49-
5048![ Shows the single selection in SfTreeView ] ( TreeViewSingleSelection.gif )
5149
5250## Multiple Items Selection
@@ -64,25 +62,23 @@ TreeView allows to select multiple items by setting the [SfTreeView.SelectionMod
6462 SelectionMode =" Multiple"
6563 FullRowSelect =" True"
6664 ItemsSource =" {Binding Nodes1}" >
67- <treeView : SfTreeView .ItemTemplate>
68- <DataTemplate >
69- <StackPanel Orientation =" Horizontal" >
70- <ContentPresenter Width =" 20"
71- Height =" 20"
72- HorizontalAlignment =" Stretch"
73- VerticalAlignment =" Center"
74- ContentTemplate =" {Binding ImageTemplate}" />
75- <TextBlock
76- Margin =" 5"
77- VerticalAlignment =" Center"
78- Text =" {Binding Header}" />
79- </StackPanel >
80- </DataTemplate >
81- </treeView : SfTreeView .ItemTemplate>
82- </treeView : SfTreeView >
83-
65+ <treeView : SfTreeView .ItemTemplate>
66+ <DataTemplate >
67+ <StackPanel Orientation =" Horizontal" >
68+ <ContentPresenter Width =" 20"
69+ Height =" 20"
70+ HorizontalAlignment =" Stretch"
71+ VerticalAlignment =" Center"
72+ ContentTemplate =" {Binding ImageTemplate}" />
73+ <TextBlock Margin =" 5"
74+ VerticalAlignment =" Center"
75+ Text =" {Binding Header}" />
76+ </StackPanel >
77+ </DataTemplate >
78+ </treeView : SfTreeView .ItemTemplate>
79+ </treeView : SfTreeView >
8480 ```
85-
81+
8682 ![ Shows the multiple selection in SfTreeView] ( TreeViewMultipleSelection.gif )
8783
8884## Programmatic Selection
@@ -121,10 +117,9 @@ The [SelectionChanging](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.
121117``` C#
122118
123119treeView .SelectionChanging += OnSelectionChanging ;
124-
125- private void OnSelectionChanging (object sender , Syncfusion . UI . Xaml . TreeView . ItemSelectionChangingEventArgs e )
120+
121+ private void OnSelectionChanging (object sender , ItemSelectionChangingEventArgs e )
126122{
127-
128123}
129124
130125```
@@ -140,10 +135,9 @@ The [SelectionChanged](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.T
140135``` C#
141136
142137treeView .SelectionChanged += OnSelectionChanged ;
143-
144- private void OnSelectionChanged (object sender , Syncfusion . UI . Xaml . TreeView . ItemSelectionChangedEventArgs e )
138+
139+ private void OnSelectionChanged (object sender , ItemSelectionChangedEventArgs e )
145140{
146-
147141}
148142
149143```
@@ -157,22 +151,16 @@ TreeView selection for specific items can be disabled by setting the **ItemSelec
157151``` C#
158152
159153treeView .SelectionChanging += OnSelectionChanging ;
160-
161- private void OnSelectionChanging (object sender , Syncfusion . UI . Xaml . TreeView . ItemSelectionChangingEventArgs e )
154+
155+ private void OnSelectionChanging (object sender , ItemSelectionChangingEventArgs e )
162156{
163157 if (e .AddedItems .Count > 0 )
164158 {
165- // disable the selection for specific items by setting the ItemSelectionChangingEventArgs.Cancel property to true.
166- if ((e .AddedItems [0 ] as Model ).Header == " Overall Project Plan.docx" || (e .AddedItems [0 ] as Model ).Header == " Server" )
167- e .Cancel = true ;
159+ // disable the selection for specific items by setting the ItemSelectionChangingEventArgs.Cancel property to true.
160+ if ((e .AddedItems [0 ] as Model ).Header == " Overall Project Plan.docx" || (e .AddedItems [0 ] as Model ).Header == " Server" )
161+ e .Cancel = true ;
168162 }
169163}
170164
171165```
172-
173166Take a moment to peruse the [ WinUI TreeView - Selection] ( https://help.syncfusion.com/winui/treeview/selection ) documentation, where you can find about selection with code examples.
174-
175- ## Requirements to run the demo
176-
177- Visual Studio 2019 and above versions.
178-
0 commit comments