Maximize productivity with
30% off* for a limited time
using BOOSTDEV30.
Includes 3- and 5-packs.
*Some exclusions may apply.New Product LaunchBoldDesk: Help desk ticketing software starts at $10 for 3 agents.
Try it for free.
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() } }); |