diff --git a/README.md b/README.md index c74cdc2..d517d69 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,44 @@ -# How to customize the style of tree nodes based on its level using converter in wpf treeview? -This repository describes how to customize the style of tree nodes based on its level using converter in wpf treeview +# How to customize the style of tree nodes based on its level using converter in WPF TreeView + +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). + +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). + +#### XAML + +``` xml + + + + + + + + + + + + + + + +``` +#### C# + +``` csharp +public class FontAttributeConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var level = (int)value; + return level == 0 ? FontWeights.Bold : FontWeights.Regular; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} +``` \ No newline at end of file