diff --git a/README.md b/README.md index 81d4c79..364066f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,76 @@ -# How to load images in a cell in winui treegrid? -This example describes how to load images in a cell in winui treegrid. +# How to load images in a cell in WinUI TreeGrid? + +This example describes how to load images in a cell in WinUI TreeGrid. + +You can add the image to [WinUI TreeGrid](https://www.syncfusion.com/winui-controls/treegrid) (SfTreeGrid) cell by using **TreeGridTemplateColumn**. + +### XAML + +``` xml + + + + + + + + + + + + + + + + + +``` + +### C# + +``` csharp +class StringToImageConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, string language) + { + string imageName = value.ToString(); + if (imageName == "US.jpg") + { + Uri uri = new Uri("ms-appx:///Images/US.jpg"); + BitmapImage image = new BitmapImage(uri); + return image; + } + + else if (imageName == "UK.jpg") + { + Uri uri1 = new Uri("ms-appx:///Images/UK.jpg"); + BitmapImage image = new BitmapImage(uri1); + return image; + } + + else + { + Uri uri1 = new Uri("ms-appx:///Images/Japan.jpg"); + BitmapImage image = new BitmapImage(uri1); + return image; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } +} +``` \ No newline at end of file