
I am generating GridViewDataColumns dynamically using following code.
var isUnReadColumn = new GridViewDataColumn
{
Header = isUnreadImage,
Width = new GridViewLength(22, GridViewLengthUnitType.Auto, 22, 22),
DataMemberBinding = new Binding(EmailMessageController.COLUMNISUNREAD)
{
Converter = new EmailBoolToReadUnreadImageConverter()
}
};
This code was working fine untill I started using new Telerik Dlls released on 14th July, 2010.
The converter here in the code is just converting boolean value to image(Open mail image for read emails and close mail image for unread email). Now after using new Dlls this code is neither generating any image through converter nor raise any exception.
Same thing is happening to all the converters in the system and none of them is working as before.
So what can be the solution to this issue..?
Thanks in advance.
4 Answers, 1 is accepted
I have tried to reproduce your problem, but everything works as expected and the the converters are properly applied.
I am sending you a sample project that you can use as a reference. In case there is some kind of misunderstanding considering your requirements, please provide us with more details about your application.
Maya
the Telerik team
I have missed to attached the sample project in the previous post, so please find it attached to this one.
Maya
the Telerik team

Thanks for the quick reply.
First of all you have implemented the Converter in xaml code where in my case I am doing it in c# code (check the code block in my last post) as I am generating all the columns programmatically.
Apart of this let me clear some other points.
1.> Generating all the columns of the GridView programmatically and not in xaml.
2.> Implementation of converter and use of converter is in two separate silverlight projects.
3.> Bringing images from a server project in my solution.
4.> Following is the Convert method that I am using.
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null && (bool)value)
{
var attachmentImage = new Image()
{
Height = 12,
Width = 12,
HorizontalAlignment = HorizontalAlignment.Center
};
attachmentImage.Source = new BitmapImage(new Uri(ImageDB.Email.WITHATTACHMENT, UriKind.RelativeOrAbsolute));
return attachmentImage;
}
else
{
return null;
}
}
Hope this helps you understanding the scenario.
Thanks again.
Indeed, following the way you are developing your converter, it turns out that is not quite applicable according to the internal logic implemented in our GridViewDataColumn in our latest versions.
However, there are a couple of possible solutions in this case. Firstly, you may define a CellTemplate for your GridViewDataColumn. For example:
<
UserControl.Resources
>
<
my:BooleanToImageConverter
x:Key
=
"BoolToImageConverter"
/>
<
DataTemplate
x:Key
=
"CellTemplate"
>
<
StackPanel
>
<
Image
Source
=
"{Binding Path=IsKoala, Converter={StaticResource BoolToImageConverter}}"
Width
=
"50"
Height
=
"50"
/>
</
StackPanel
>
</
DataTemplate
>
</
UserControl.Resources
>
GridViewDataColumn nationalityColumn = new GridViewDataColumn();
nationalityColumn.DataMemberBinding = new Binding("NationalityFlag");
nationalityColumn.IsReadOnly = true;
nationalityColumn.CellTemplate = (DataTemplate) Resources["CellTemplate"];
this.playersGrid.Columns.Add(nationalityColumn);
The other possibility is to define a GridViewImageColumn:
GridViewImageColumn nationalityColumn = new GridViewImageColumn();
nationalityColumn.DataMemberBinding = new Binding("IsKoala")
{
Converter = new BooleanToImageConverter()
};
nationalityColumn.IsReadOnly = true;
this.playersGrid.Columns.Add(nationalityColumn);
However, in both cases the value returned by your converter should be the Source of the image, not the image itself:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
{
if (value != null && (bool)value)
{
var attachmentImage = new Image()
{
Height = 12,
Width = 12,
HorizontalAlignment = HorizontalAlignment.Center
};
attachmentImage.Source = new BitmapImage(new Uri(ImageDB.Email.WITHATTACHMENT, UriKind.RelativeOrAbsolute));
return attachmentImage.Source;
}
else
{
return null;
}
}
}
I hope that helps. Please excuse us for the inconvenience caused.
Maya
the Telerik team