This is a migrated thread and some comments may be shown as answers.

GridViewImageColumn - Blurred

2 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
NoRyb
Top achievements
Rank 1
NoRyb asked on 27 Apr 2010, 07:14 AM
Hello

I'm showing an icon for every item in my RadGridView. For this, I create a GridViewImageColumn the following way:
GridViewImageColumn imgCol = new GridViewImageColumn(); 
imgCol.ImageStretch = System.Windows.Media.Stretch.None; 
imgCol.ImageWidth = 16; 
imgCol.ImageHeight = 16; 
imgCol.DataMemberBinding = binding; 

The icon is 16x16px and it's set to not stretched - still it's blurry. Now I know that this probably is not a Telerik problem because this also happens in other WPF situations. But I was trying to find something like the "SnapPixelsToDevice" or "RenderOptions.SetBitmapScalingMode" property/method.

Is there any way I can make the images look better? The Telerik-TreeView seems to work perfectly without setting any property and it uses the same images.

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvyatko
Telerik team
answered on 29 Apr 2010, 03:34 PM
Hi NoRyb,

In order to enhance the display quality of the images I can suggest to inherit the Image column and apply options on the created images. The code could look like this:

public  class GridViewClearImageColumn:GridViewImageColumn
{
    public override System.Windows.FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
    {
        var item = base.CreateCellElement(cell, dataItem);
 
        var image = item as Image;
 
        if (image != null)
        {
            image.SnapsToDevicePixels = true;
            RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.NearestNeighbor);
            item = image;
        }
 
        return item;
    }
}

I have also attached sample demonstrating the idea. If this does not help you can suggest to set the stretch mode of the image to none:
image.Stretch = Stretch.None;

Regards,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
NoRyb
Top achievements
Rank 1
answered on 30 Apr 2010, 06:42 AM
Great. That worked! Thank you very much.

Best Regards
Tags
GridView
Asked by
NoRyb
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
NoRyb
Top achievements
Rank 1
Share this question
or