Changing image path through a Style Selector

4 posts, 0 answers
  1. David
    David avatar
    20 posts
    Member since:
    Nov 2015

    Posted 30 Nov 2015 Link to this post

    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.


     
  2. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 01 Dec 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. David
    David avatar
    20 posts
    Member since:
    Nov 2015

    Posted 01 Dec 2015 in reply to Stefan X1 Link to this post

    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?

  5. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 03 Dec 2015 Link to this post

    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
Back to Top