为什么代码运行时图像不显示? [英] Why is image not showing up when the code is running?

查看:165
本文介绍了为什么代码运行时图像不显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码运行时,我的图像未显示在图像框中。请帮帮我。



我尝试过:



我的xaml代码:

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>





我的.cs代码:





My .cs code:

BitmapImage myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(@"C://image//cards//*.png");
                ImageSource imageSource = myBitmapImage;
                ImgCard.Source = imageSource;

推荐答案

您无法在URI中提供通配符:系统无法准确知道哪个文件你的意思,所以不会加载任何文件。您必须指定单个图像文件的完整路径。
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.


这篇关于为什么代码运行时图像不显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆