【问题标题】:xaml image not showing .sourcexaml 图像未显示 .source
【发布时间】:2012-05-08 06:58:05
【问题描述】:

总的来说,我是 xaml 和 wpf 的新手。 我正在尝试使图像出现在用户控件中,这是我使用的代码:

   BitmapImage captchaSource = new BitmapImage();
                        captchaSource.BeginInit();
                        captchaSource.UriSource = new Uri(_captchaData.ImgUrl);
                        captchaSource.EndInit();
                        captchaImg.Source = captchaSource;

这是用户界面代码:

<Image Height="105" HorizontalAlignment="Left" Margin="12,38,0,0" Name="captchaImg" Stretch="Fill" VerticalAlignment="Top" Width="276" Grid.ColumnSpan="2" />

但是什么也没发生。没有图像出现。这是 _captchaData.ImgUrl http://www.google.ro/images/srpr/logo3w.png 中的 url

有人知道这是为什么吗?

【问题讨论】:

标签: wpf image xaml


【解决方案1】:

来自previous question

"WebURL 不能作为 UriSource 属性的源提供 位图图像。如果是 weburl,则需要在本地下载该图像 并将该路径绑定到 UriSource。”

【讨论】:

    猜你喜欢
    • 2021-08-18
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 2019-03-22
    • 1970-01-01
    • 2021-04-13
    • 1970-01-01
    相关资源
    最近更新 更多