How to set image source code behind in silverlight

30 Mar

Hi  Dear…

if your want to change image dynamically of RadGridview in Silverlight with specific Condition then your use this code and be happy


<telerik:GridViewColumn Width=”auto”>

<telerik:RadButton  x:Name=”lbtnInActive”   Command=”Edit” CommandParameter=”{Binding Listidpk}” Click=”lbtnInActive_Click”  >
<StackPanel Orientation=”Horizontal” Margin=”0″>
<Image Source=”../Images/icon-Active.png” Width=”30″ Height=”31″ x:Name=”activeICon”/>


private void grdList_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
if (e.DataElement != null)
if (e.Row.DataContext != null)
var button = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “lbtnInActive”).FirstOrDefault();
var imgicon = e.Row.ChildrenOfType<Image>().Where(b => b.Name == “activeICon”).FirstOrDefault();
tbllists tblst = e.Row.DataContext as tbllists;

if (Convert.ToString(tblst.Liststatus)== “Active”)
button.Tag = “Active”;
ToolTipService.SetToolTip(button, “Change Status To InActive”);
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-Active.png”, UriKind.RelativeOrAbsolute));

else if (Convert.ToString(tblst.Liststatus)==”InActive”)

button.Tag = “InActive”;
ToolTipService.SetToolTip(button, “Change Status To Active”);
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-inactive.png”, UriKind.RelativeOrAbsolute));

else {
button.Tag = “Active”;
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-pending.png”, UriKind.RelativeOrAbsolute));
ToolTipService.SetToolTip(button, “Change Pendding To Active”);



Leave a comment

Posted by on March 30, 2012 in Silverlight


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: