【问题标题】:Load image into XAML Image将图像加载到 XAML 图像中
【发布时间】:2014-04-24 00:24:38
【问题描述】:

如何将图像加载到图像中?我试过了

        private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        string path = "D:/baby.jpg";
        BitmapImage bitmap = new BitmapImage(new Uri(path, UriKind.Relative));
        imagebox.Source = bitmap;
    }

但是当我点击按钮时,什么也没发生。我做错了什么?

【问题讨论】:

    标签: c# xaml windows-runtime windows-store-apps winrt-xaml


    【解决方案1】:

    Windows 应用商店应用不支持绝对路径。您需要使用其中一种有效的方案,但这不适用于根目录中的文件。在这种情况下,您将需要使用文件选择器之类的东西访问 StorageFile,并在从文件打开的流上调用 imagebox.SetSource()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多