我正在使用xamarin.forms。本地图像不具有约束力。图片文件夹
检索图像的代码是
public const string RESOURCE_CIRCLE = "RadioCheckNoPlugin.Controls.Resources.circle.png";
public const string RESOURCE_DOT = "RadioCheckNoPlugin.Controls.Resources.dot.png";
public IconView iconCircle = new IconView { Source = ImageSource.FromResource(RESOURCE_CIRCLE), FillColor = GlobalSetting.BorderColor, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, HeightRequest = GlobalSetting.Size, WidthRequest = GlobalSetting.Size };
public IconView iconChecked = new IconView { Source = ImageSource.FromResource(RESOURCE_DOT), FillColor = GlobalSetting.Color, IsVisible = false, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, HeightRequest = GlobalSetting.Size, WidthRequest = GlobalSetting.Size };
图片属性 Build Action:Embedded resource ,我没有收到任何错误。我尝试通过也删除.png扩展名,但它没有约束力。 请帮助我如何绑定图像。
答案 0 :(得分:0)
如下更改图像路径常量:
public const string RESOURCE_CIRCLE = "resource://RadioCheckNoPlugin.Controls.Resources.circle.png";
public const string RESOURCE_DOT = "resource://RadioCheckNoPlugin.Controls.Resources.dot.png";