StackPanel loded is not getting fired in.cs page
- by prince23
<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.