I made this windows phone user control:

XAML:
<Grid x:Name="LayoutRoot" Height="75" Width="353">
<Image Height="50" HorizontalAlignment="Left" Margin="12,12,0,0" Name="img" Stretch="Fill" VerticalAlignment="Top" Width="50" />
<TextBlock Height="50" HorizontalAlignment="Left" Margin="77,12,0,0" Name="txt" Text="TextBlock" VerticalAlignment="Top" Width="215" FontSize="32" />
<CheckBox Content="CheckBox" Height="68" HorizontalAlignment="Right" Margin="0,3,10,0" Name="cb" VerticalAlignment="Top" Width="50" />
</Grid>
And I call it like that in one of my pages
XAML.CS:
myListBox mls = new myListBox();
String[,] ls = { { "Text1", "/image/image1.png" }, { "Tex2", "/image/image2.png" } };
for (int i = 0; i < 2; i++)
{
mls.txt.Text = ls[i, 0];
mls.img.Source = url(ls[i, 1]);
}
public ImageSource url (string path)
{
Uri uri = new Uri(path, UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
return imgSource;
}
My problems are:
1) If I run this like that it take to the code below but if i change for loop to i<1 it working fine (but not exactly what i expect look problem 2)
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
2) With this code I set text and image but it not placing the image, only the text.
I have a similar working code and I have used UriKind as ‘Relative‘ and not ‘Absolute’.
And one more thing. Make sure the ‘Build Action’ under the properties of the image which you’re using is set to ‘Content’ and NOT ‘Resource’ or anything else.
Hopefully it’ll work.