I have an Image control. When the image is clicked at runtime it should be added to a grid as a child. I have implemented this.
My requirement now is when the image (which is now inside a grid) is tapped I need a border around the image. How can I achieve this?
I have added the following code inside image tapped but cannot see the border
Border b = new Border();
b.BorderThickness = new Thickness(4);
img1 = new Image();
img1.MaxHeight = 300;
img1.MaxWidth = 500;
b.Child = img1;
img1.Source = new BitmapImage((new Uri(imgPath, UriKind.RelativeOrAbsolute)));
grid1.Children.Add(b);
Instead of droping the image as a grid cell child, create a Border object and put the image inside as a content.
Initially, the border can have BorderBrush transparent and thickness = 1 or other. Then, add the Tapped event to the image to modify the border brush color.
Based in your code above, you need something like