In my windows phone app, I have a rectangular Border. I want to add image in the center of the border. How to do that using C# ?
Edit
This code is not displaying any image. Any idea why ?
Border b = (Border)FindName("border"+nom);
if (move == 1)
{
var bi = new BitmapImage
{
UriSource = new Uri("/Images/smiley1.png", UriKind.Relative)
};
b.Child = new Image { Source = bi };
}
Edit 2
Apparently, correct syntax is UriSource = new Uri("/BoxIt;component/Images/smiley1.png", UriKind.Relative)
This solves the problem 🙂
an Image can be adeed to a Border using following code:
Note: I do not recommend this. DataTemplates with Data binding or TemplatedControls should be used when possible.