Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142776 | Feb 19,2019 03:37 PM UTC | Feb 20,2019 11:34 AM UTC | WPF | 1 |
![]() |
Tags: SfDataGrid |
public class BoolToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var isAvailable = bool.Parse(value.ToString());
string imageName = isAvailable ? "Green.png": "Red.png";
return new BitmapImage(new Uri(string.Format(@"..\..\Images\{0}", imageName), UriKind.Relative));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |
sfdatagrid.Columns.Add(new GridImageColumn() { MappingName = "IsAvailable", ValueBinding = new Binding() { Path = new PropertyPath("IsAvailable"), Converter = new BoolToImageConverter() } }); |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.