Open robertorp opened 5 years ago
How to set resource embedded for image?
example:
<views:FloatingActionButton HorizontalOptions="CenterAndExpand" Command="{Binding NovoClienteCommand}" VerticalOptions="CenterAndExpand" Image="{resources:ImageResource plus.png}" ButtonColor="#03A9F4" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-90}" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-90}" />
[ContentProperty(nameof(Source))] public class ImageResourceExtension : IMarkupExtension { public string Source { get; set; } public object ProvideValue(IServiceProvider serviceProvider) { if (Source == null) { return null; } var imageSource = ImageSource.FromResource(ImageNameFromResource(Source), typeof(ImageResourceExtension).GetTypeInfo().Assembly); return imageSource; } private string ImageNameFromResource(string u) { var assembly = typeof(App).GetTypeInfo().Assembly; foreach (var res in assembly.GetManifestResourceNames()) { if (res.Contains(u)) { return res; } } return null; } }
How to set resource embedded for image?
example: