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

Changing image path through a Style Selector

3 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 30 Nov 2015, 04:36 PM

Hi there,

 I'm sure this has been asked before. I have a column where the value needs to be represented by an icon. For example, I want the value of "1" to be represented by an image located in a local folder. Can I do this with a CellStyleSelector? Or do I need to use a CellTemplateSelector? Or is there any easier way to do this?

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding Priority}" Header="P" Width="20">
       <telerik:GridViewDataColumn.CellTemplate>
           <DataTemplate>
                <Image Source="[WHAT GOES HERE?]" />
           </DataTemplate>
       </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Thanks.


 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Dec 2015, 12:46 PM
Hi David,

For achieving this, I suggest you using the built in GridViewImageColumn that RadGridView supports instead of GridViewDataColumn with a predefined template and CellStyleSelector.

I have also attached a demo application for your convenience. Can you please check it out and let me know whether it corresponds to your needs?

Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 01 Dec 2015, 07:33 PM

I see how the sample project you posted is changing the image, but I don't see how it's implementing a CellStyleSelector. From what I can see it's only implementing a straight GridViewImageColumn.

Can you show me how to implement a CellStyleSelector with a DataTemplate?

0
Stefan
Telerik team
answered on 03 Dec 2015, 11:21 AM
Hello David,

I am afraid that such requirements cannot be achieved through CellStyleSelector, as it defines a Style targeting GridViewCell. Note, that modifying the DataMemberBinding of a column through it is not possible. An appropriate solution for this case is to use CellTemplateSelector and define an Image control with its Source pointing to each needed image.

I hope the suggestion fits your requirements.

Best Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Stefan
Telerik team
David
Top achievements
Rank 1
Share this question
or