Skip to content

Commit 1ab3b0d

Browse files
ES-975464 - Resolve the ReadMe issue in this sample repository
1 parent 2eeea09 commit 1ab3b0d

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# How to customize the style of tree nodes based on its level using converter in wpf treeview?
2-
This repository describes how to customize the style of tree nodes based on its level using converter in wpf treeview
1+
# How to customize the style of tree nodes based on its level using converter in WPF TreeView
2+
3+
This repository describes how to customize the style of tree nodes based on its level using converter in [WPF TreeView](https://www.syncfusion.com/wpf-controls/treeview) (SfTreeView).
4+
5+
The TreeView allows you to customize the style of [TreeViewItem](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeView.TreeViewItem.html) based on different levels by using [IValueConverter](https://docs.microsoft.com/en-us/dotnet/api/system.windows.data.ivalueconverter?view=netcore-3.1).
6+
7+
#### XAML
8+
9+
``` xml
10+
<Window.Resources>
11+
<local:FontAttributeConverter x:Key="FontAttributeConverter"/>
12+
</Window.Resources>
13+
<Window.DataContext>
14+
<local:MailFolderViewModel x:Name="viewModel"/>
15+
</Window.DataContext>
16+
17+
<Grid>
18+
<Syncfusion:SfTreeView HorizontalAlignment="Left" ItemTemplateDataContextType="Node" ItemsSource="{Binding Folders}" ChildPropertyName="SubFolder" >
19+
<Syncfusion:SfTreeView.ItemTemplate>
20+
<DataTemplate>
21+
<Label Content="{Binding Content.FolderName}" FontWeight="{Binding Level, Converter={StaticResource FontAttributeConverter}}"
22+
FontSize="14"/>
23+
</DataTemplate>
24+
</Syncfusion:SfTreeView.ItemTemplate>
25+
</Syncfusion:SfTreeView>
26+
</Grid>
27+
```
28+
#### C#
29+
30+
``` csharp
31+
public class FontAttributeConverter : IValueConverter
32+
{
33+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
34+
{
35+
var level = (int)value;
36+
return level == 0 ? FontWeights.Bold : FontWeights.Regular;
37+
}
38+
39+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
40+
{
41+
throw new NotImplementedException();
42+
}
43+
}
44+
```

0 commit comments

Comments
 (0)