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

Dynamically change image in CellTemplate column

2 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kavi
Top achievements
Rank 1
Kavi asked on 07 Aug 2010, 07:04 AM
Hi,

How do i dynamically change the image of the radgrid view template column?

<telerikGridView:GridViewColumn Header="pic" >
  <telerikGridView:GridViewColumn.CellTemplate>
    <DataTemplate x:Name="dtProjectEdit">
       <Button x:Name="btnimg">
          <Image x:Name="img" Source="/Images/pic.jpg" />
       </Button>
     </DataTemplate>
  </telerikGridView:GridViewColumn.CellTemplate>
</telerikGridView:GridViewColumn>

2 Answers, 1 is accepted

Sort by
0
Gaurav
Top achievements
Rank 1
answered on 07 Aug 2010, 02:27 PM
Use a data convertor class and bind to the control. Here is an eg.

XAML

<TextBlock Text="{Binding ReleaseDate, Converter={StaticResource StringConverter}" />

C#

public class StringFormatter : IValueConverter
{public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string formatString = parameter as string;
 if (!string.IsNullOrEmpty(formatString))
 { return string.Format(culture, formatString, value);
 } 
 return value.ToString();

ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{ throw new NotImplementedException();
}
}


In your case toggle the image path in the same way.
0
Vlad
Telerik team
answered on 09 Aug 2010, 06:48 AM
Hi,

 You can use also our template selectors

Kind regards,
Vlad
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
Tags
GridView
Asked by
Kavi
Top achievements
Rank 1
Answers by
Gaurav
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or