Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My image is not showing up in the image box when the code is running. please help me with this.

What I have tried:

My xaml code:
<Canvas HorizontalAlignment="Left" Height="198" Margin="10,59,0,0" VerticalAlignment="Top" Width="144" Background="#FFF9F4F4">
            <Image Name="ImgCard" Height="178" Width="112" Canvas.Top="6" Canvas.Left="16"/>
        </Canvas>


My .cs code:

BitmapImage myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(@"C://image//cards//*.png");
                ImageSource imageSource = myBitmapImage;
                ImgCard.Source = imageSource;
Posted
Updated 5-May-17 23:08pm
Comments
Nirav Prabtani 6-May-17 5:35am    
I don't understand why "*" sign is there?

Just make sure path is accessible for the image and your code will work.
Member 13170154 6-May-17 9:18am    
I removed the * but still it didn't show up

1 solution

You cannot supply wildcards in a URI: the system doesn't know exactly which file you meant, so no file will be loaded. You must specify a full path to a single image file.
 
Share this answer
 
Comments
[no name] 6-May-17 6:18am    
I tried it www.*.*, I'm waiting now ...
OriginalGriff 6-May-17 6:50am    
Congratulations! You haz won the internetz! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900