StackPanel loded is not getting fired in.cs page
Posted
by prince23
on Stack Overflow
See other posts from Stack Overflow
or by prince23
Published on 2010-05-18T15:46:02Z
Indexed on
2010/05/18
16:00 UTC
Read the original article
Hit count: 234
silverlight-4.0
<sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Loaded ="SPImage_Loaded" Orientation="Horizontal" Background="Transparent" >
<Button x:Name="myButton"
Click="Btn_Click">
<Image x:Name="imgMarks" " Stretch="None"/>
</Button>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
in .cs i have defined the event for stack panel
private void SPImage_Loaded(object sender, RoutedEventArgs e) { try { var TargetMarks = sender as StackPanel; Image imgMarks= (Image)TargetScore.FindName("imgMarks");
Marks obj = (Marks )TargetMarks.DataContext;
// here marks oject would be containg the details
// here if marks.score object value is 1 then bind the image
//else
// dnt bind the image . that is logic i am trying to do.
imgMarks.Source = new BitmapImage(new Uri("/Images/a1.png", UriKind.Relative));
}
catch (Exception)
{
throw;
}
}
any solution on this would be great. is there any better solution to achive this. plz help me out.
thank you.
© Stack Overflow or respective owner