【问题标题】:How to set Image Source to a picture from .dll or .winmd in windows phone 8.1?如何在 windows phone 8.1 中将图像源设置为来自 .dll 或 .winmd 的图片?
【发布时间】:2014-12-08 09:26:02
【问题描述】:

我是 windows phone 8.1 开发新手,专注于 library dev
wp 8.0时代,我知道要不要创建Image实例。
我只是写

amapLogo.Source = new BitmapImage(new Uri("/Com.AMap.Api.Maps" + ";component/Resources/ap2.data", UriKind.Relative));

这里需要指出的是,“/Com.AMap.Api.Maps”是我的库输出 dll
它工作正常。

如果我在 wp8.1 开发中保留相同的代码
出现异常

An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details.

我浏览http://go.microsoft.com/fwlink/?LinkID=215849
并找到正确设置 ImageSource 的两种方法。
ms-appxms-appx-web 方案来创建绝对 URI。
但它用于获取应用程序包中的资源
我想要的是从我的 dll 中获取资源
所以

  • 如何使用设置方式创建 Image 实例 图像源。
  • 或者有其他方法可以做我想做的事吗?

谢谢!

【问题讨论】:

    标签: windows-runtime windows-phone-8.1


    【解决方案1】:

    只要解决它!

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965322.aspx

    要访问存储在同一个包中但来自类库的文件,请使用类库名称:

    <Image Source="/ClassLibraryName/images/logo.png" />
    

    【讨论】:

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