【问题标题】:Access Images from Phone Class Library从电话类库访问图像
【发布时间】:2014-01-30 15:31:14
【问题描述】:

我用 MainPage.xaml 创建了一个电话类库(名称为 Base)。我在我的子项目中链接这个文件。由于所有类文件都是从 Base 链接的,因此我可以运行子项目。

我面临的问题是,我想从我的子项目(存在于我的子项目中)中访问图像文件。例如,我在 Assets 文件夹中有我的子项目的图像。我的代码是

Image image = new Image();
Uri imageUri = new Uri("Assets/Topic1.png", UriKind.Relative);
image.Source = new BitmapImage(imageUri);
image.Width = 48;
image.Height = 48;
ContentPanelChildren.Add(image);

这段代码没有显示我在“Assets/Topic1.png”位置的图片。

如何显示图像?

谢谢。

【问题讨论】:

    标签: c# xaml visual-studio-2012 windows-8 windows-phone-8


    【解决方案1】:

    尝试将 Uri 行更改为:

    Uri imageUri = new Uri("/ASSEMBLY NAME;component/Assets/Topic1.png", UriKind.Relative);
    

    将“ASSEMBLY NAME”替换为您的程序集名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-21
      • 2012-08-09
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多