【问题标题】:display image in silverlight 4在silverlight 4中显示图像
【发布时间】:2011-09-14 14:40:55
【问题描述】:
private void button1_Click(object sender, RoutedEventArgs e)
{
  MyImage.Source = new BitmapImage(new Uri("../Image/" + txtImage.Text,
                                   UriKind.Relative));
}  

为什么图片不显示?

【问题讨论】:

  • 欢迎来到 Stack Overflow。为了回答这个问题,我们需要更多的信息和上下文。究竟出了什么问题?
  • +1:我添加了他们可能想问的问题。 Silverlight 中的 URL 有一些人们需要注意的曲折。出于这个原因,我加回一票,因为 -2 有点苛刻:)

标签: wpf silverlight


【解决方案1】:

您的相对 URI 不能包含,尤其是以 "../" 开头。

除非它以"/" 开头,或者以"http://" 开头的绝对URL,否则它被假定在一个模块中。

"/images/imagename.jpg" 之类的 URL 将在托管网站的 clientbin/images 文件夹中找到图像。

还可以在这里查看我的答案以获取更多信息:Binding image in Isolated Storage

【讨论】:

    猜你喜欢
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多