Image shown in app when read from base64, but not shown when read from file

77 views Asked by At

This is my code:

BitmapImage bitmapImage;

if (ImagesInBase64[imageName.ToString()].Equals(string.Empty))
{
    bitmapImage = new BitmapImage(new Uri(string.Format("{0}\\Images\\Application\\{1}.png", AppDomain.CurrentDomain.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar), imageName), UriKind.Relative));                    
}
else
{
    bitmapImage = ImageProcessor.Base64StringToBitmap(ImagesInBase64[imageName.ToString()]);

    ImageProcessor.SaveMyImage(ImagesInBase64[imageName.ToString()], imageName);
}

var image = new Image();
image.Source = bitmapImage;

image.SetValue(Grid.RowProperty, row);
image.SetValue(Grid.ColumnProperty, column);
image.Margin = new Thickness(10, 5, 10, 5);
grid.Children.Add(image);

When the code enters in the else, everything works as expected. I can see the image as a part of the grid. However, when the code enters the if part, even though bitmapImage is a valid BitmapImage, the image isn't shown in the grid. WHat's going on?

0

There are 0 answers