【发布时间】:2018-08-08 02:12:21
【问题描述】:
我有以下情况:
- 我们拥有/构建了一个 Xamarin.Forms 库,其中还应包含我们的常用图标
- 此图标应在此库中的 XAML 时代使用,但也应在最终应用中使用
库结构
Base.Library (.Net Standard 2.0 + Xamarin.Forms)
|- Views (XAML)
Base.Library.Android
|- Resources
|- drawables
|- icon.xml
Base.Library.iOS
|- Assets
|- icon (image asset with 3 resolutions)
Base.Library.Upw
|- Icons
|- icon.scale-100.png
|- ...
|- icon.scale-400.png
这些图标可以在 iOS 和 Android 上正常工作(在 ibrary 项目的 XAML 页面和使用该库的最终应用项目中)。
<Image WidthRequest="24" HeightRequest="24" VerticalOptions="Center"
HorizontalOptions="End">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<On Platform="Android,iOS" Value="icon" />
<On Platform="UWP" Value="Icons/icon.png" />
</OnPlatform>
</Image.Source>
</Image>
只有 UWP 不起作用。是从库中加载图片的特殊语法吗?
我已经尝试了以下方法:
// Prefixed with assembly name of the library
Value="ms-appx:///Base.Library.Uwp/Icons/icon.png"
// Prefixed with namespace of the library
Value="ms-appx:///Base.Library.Uwp.Namespace/Icons/icon.png"
【问题讨论】:
标签: image xamarin.forms uwp resources xamarin.uwp