From dd7932db4b091afda14fb95d59883c6e6911eb1b Mon Sep 17 00:00:00 2001 From: Rodja Trappe Date: Mon, 10 Dec 2018 10:28:20 +0100 Subject: [PATCH] Describe how to add images to shared project and reference them. --- Demo/ImageModule.cs | 8 ++++++++ InterfaceBuilder/UI.cs | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Demo/ImageModule.cs b/Demo/ImageModule.cs index 41c44d2..6b86c0d 100644 --- a/Demo/ImageModule.cs +++ b/Demo/ImageModule.cs @@ -15,6 +15,14 @@ public ImageModule(UI ui) : base(ui) Page = ui.NavigationPage( ui.Page("Images", ui.Stack().With( + ui.Label(@" +Add the images to your shared +project and set 'Build Action' +to EmbeddedRessource. + +Also provide a 'Ressource ID' +which you can then reference +in UI.Image(string ressourceId)").Height(150).FontSize(22), ui.Box().FillVertical(), ui.Label("Designed by Starline / Freepik:"), ui.Image("loremipsum.jpg") diff --git a/InterfaceBuilder/UI.cs b/InterfaceBuilder/UI.cs index a07fc67..f2ceaf8 100644 --- a/InterfaceBuilder/UI.cs +++ b/InterfaceBuilder/UI.cs @@ -20,6 +20,7 @@ public Label Label(string text = "") HeightRequest = Theme.Sizes.NormalFont * 2, VerticalTextAlignment = TextAlignment.Center, Margin = new Thickness(Theme.Sizes.NormalFont, 0), + LineBreakMode = LineBreakMode.WordWrap, }.Text(text); } @@ -32,7 +33,7 @@ public Button Button(string text = "") }; } - public Image Image(string resourcename = "") + public Image Image(string resourceId = "") { var stackTrace = new System.Diagnostics.StackTrace(); var frame = stackTrace.GetFrames()[1]; @@ -41,7 +42,7 @@ public Image Image(string resourcename = "") var methodsClass = method.DeclaringType; return new Image { - Source = ImageSource.FromResource(resourcename, methodsClass.Assembly), + Source = ImageSource.FromResource(resourceId, methodsClass.Assembly), Aspect = Aspect.AspectFit, }; }