locked
Forms9Patch: Simplify multi-device image management in your PCL Xamarin.Forms mobile apps RRS feed

  • Question

  • User2122 posted

    Announcement of Form9Patch

    Xamarin Forms is great for developing apps on Android and iOS but it is missing two important tools for developers: scalable images and PCL multi-screen image management. Android developers use NinePatch bitmaps and the drawable directory naming convention for this purpose. Likewise, iOS developers use ResizeableImageWithCapInsets and the @2x, @3x, @4x file naming convention for this purpose.

    Forms 9 Patch enhances Xamarin Forms to enable multi-resolution / multi-screen image management to PCL apps for iOS and Android.

    What is it?

    Simply stated, Forms9Patch is two separate elements (Image and ImageSource) which are multi-screen / multi-resolution extensions of their Xamarin Forms counterparts.

    Forms9Patch.ImageSource

    Xamarin Forms provides native iOS and Android multi-screen image management (described here). This requires storing your iOS images using the native iOS schema and storing your Android images using the Android schema. In other words, duplicative efforts to get the same results on both Android and iOS. Forms9Patch.ImageSource extends Xamarin.Forms.ImageSource capabilities to bring multi-screen image management to your PCL assemblies - so you only have to generate and configure your app's image resources once. Forms9Patch.ImageSource is a cross-platform implementation to sourcing multi-screen images in Xamarin Forms PCL apps as embedded resources.

    Forms9Patch.Image

    Forms9Patch.Image compliments Xamarin.Forms.Image to provide Xamarin Forms with a scaleable image element. Scalable images are images that fill their parent view by stretching in designated regions. The source image for the Forms9Patch.Image element can be specified either as a Forms9Patch.ImageSource or a Xamarin.Forms.ImageSource. Supported file formats are NinePatch (.9.png), .png, .jpg, .jpeg, .gif, .bmp, and .bmpf.

    Example code

    After adding the file bubble.9.png to your PCL project assembly as an EmbeddedResource, you can display it using something like the following:

    var bubbleImage = new Forms9Patch.Image () { Source = ImageSource.FromResource("MyDemoApp.Resources.bubble.9.png"), HeightRequest = 110, } var label = new label () { Text = "Forms9Path NinePatch Image", HorizontalOptions = LayoutOptions.Center, }

    Example XAML

    In Xamarin Forms, access to embedded resources from XAML requires some additional work. Unfortunately, Forms9Patch is no different. As with Xamarin Forms, you will need (in the same assembly as your embedded resource images) a simple custom XAML markup extension to load images using their ResourceID.

    ```
    [ContentProperty ("Source")] public class ImageMultiResourceExtension : IMarkupExtension { public string Source { get; set; }

        public object ProvideValue (IServiceProvider serviceProvider)
        {
            if (Source == null)
                return null;
    
            // Do your translation lookup here, using whatever method you require
            var imageSource = Forms9Patch.ImageSource.FromMultiResource(Source);
    
            return imageSource;
        }
    }
    

    ```

    Once you have the above, you can load your embedded resource images as shown in the below example. Be sure to add a namespace for the assembly that contains both your MarkupExtension and your EmbeddedResources (local in the below example). <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyXamlDemo;assembly=MyXamlDemo" x:Class="MyXamlDemo.MyPage" Padding="5, 20, 5, 5"> <ScrollView> <ScrollView.Content> <StackLayout> <Label Text="Xamarin.Image"/> <Image Source="{local:ImageMultiResource Forms9PatchDemo.Resources.image}"/> </StackLayout> </ScrollView.Content> </ScrollView> </ContentPage>

    Where to learn more

    Project page: http://Forms9Patch.com Nuget page: https://www.nuget.org/packages/Forms9Patch/0.9.1 Demo app repository: https://github.com/baskren/Forms9PatchDemo

    Monday, January 4, 2016 7:25 PM

All replies

  • User2122 posted

    Version 0.9.5 (https://www.nuget.org/packages/Forms9Patch) is now available. This release adds the following functionality:

    1. Forms9Patch.Image now supports AspectFill, AspectFit, Fill and Tile fills when the image is not a scalable image (not NinePatch or CapInsets is not set).
    2. new Forms9Patch.ContentView extends Xamarin.Forms.ContentView by adding the ability to use a Forms9Patch.Image as BackgroundImage!
    3. new Forms9Patch.Frame extends Xamarin.Forms.Frame by:
      • adding the ability to use a Forms9Patch.Image as BackgroundImage!
      • adding the OutlineWidth and OutlineRadius properties (from when a BackgroundImage is not available)
    Thursday, January 21, 2016 3:40 PM
  • User2122 posted

    Version 0.9.7 is now available with some great enhancements:

    • Forms9Patch.Image now has tinting via the TintColor property.
    • The Forms9Patch versions of ContentView, Frame, AbsoluteLayout, Grid, RelativeLayout, and StackLayout support using a Forms9Patch.Image as a background - which means it can be NinePatch scaled, aspect filled, aspect fitted, stretched to fit, or tiled.
    • The Forms9Patch versions of Frame, AbsoluteLayout, Grid, RelativeLayout, and StackLayout support a background outline with color, width and radius properties. If the BackgroundColor property is set, the HasShadow works (on Android, too) and the ShadowInverse property gives it a recessed appearance.
    • Forms9Patch.ImageButton: an image button that can change the background image, foreground image, text, and text formatting depending on button state (default, selected, disabled, disabled+selected).
    • Forms9Patch.MaterialButton: a convenience element, loosely based on the Material design language, with foreground image and text. Here are some examples:

      MaterialButton examples

    Also, I should have noted a long time ago that the Forms9Patch.ImageSource, and the non-image portions of Frame, AbsoluteLayout, Grid, RelativeLayout, StackLayout, and MaterialButton are free to use without a license.

    You can learn more and see examples at http://Forms9Patch.com

    Thursday, January 28, 2016 9:35 PM
  • User2122 posted

    Version 0.9.8.1 is now available and has an enhancement I've very proud of: MaterialSegmentedControl. This element is segmented button element (like iOS's UISegmentedControl) with a great deal more flexibility:

    • vertical and horizontal orientation
    • segments can have image and labels in vertical and horizontal orientation
    • control of outline (color, width, radius)
    • shadow works on Android
    • control of separator width

    Take a look at http://Forms9Patch.com for documentation and examples.

    Friday, February 5, 2016 4:37 PM
  • User2122 posted

    Version 0.9.9.3 is now available. All button response times and Forms9Patch.ImageSource.FromMultiResource and Forms9Patch.ImageSource.FromResource image loading times are as good (and some cases better) than their Xamarin.Forms counterparts. ImageButton now has the PressingState - which allows you to define the appearance of the button while it is being pressed by the user. All the buttons (including the MaterialSegmentedControl) have the LongPressing and LongPressed events.

    Tuesday, March 1, 2016 8:11 PM
  • User2122 posted

    Version 0.9.10 is now available and it has a very special addition - Modal and Bubble popups!

    GIF of Modal Popup

    GIF of Bubble Popup on iPhone

    GIF of Bubble Popup on Android

    These automatically place the popup over the top most Xamarin.Forms.Page (unless you chose another page). Choosing the target of a Forms9Patch.BubblePopup is just of matter of setting the Target property to a Xamarin.Forms.View.

    There's a lot more information about them at http://Forms9Patch.com

    Saturday, March 12, 2016 11:27 PM
  • User1884 posted

    Do CapInsets work on Droid as well? I have a solution that is working perfectly on iOS but with android it is doing some weird stuff.

    Friday, March 18, 2016 8:46 PM
  • User2122 posted

    @AlanSpires

    Yes, it should work on Droid just as well (it is used in the demo app as such).

    ``` new Forms9Patch.Image { Source = ImageSource.FromUri(new Uri("http://buildcalc.com/forms9patch/demo/redribbon.png")), CapInsets = new Thickness(23,0,111,0), },

    ```

    That being said, there is a chance you've tripped over a bug. Can you share with me a sample project that demonstrates what you are seeing?

    • Ben
    Friday, March 18, 2016 9:13 PM
  • User120969 posted

    The Modal and Bubble popups look very interesting and I could definitely use them, but only once there is Windows 8.1 (desktop) support because the app needs to support Android, iOS and Windows RT.

    Friday, March 18, 2016 10:05 PM
  • User1884 posted

    I don't have time right this second for a repo but here are some images showing what I'm seeing.

    Image before a simple up - down scroll https://dropbox.com/s/hqo5kabi4qgyclg/Before%20Scroll.png?dl=0

    Image after a up - down scroll https://dropbox.com/s/kp7fgb2253njc9d/After%20Scroll.png?dl=0

    Not sure what's happening there.

    Thanks!

    Friday, March 18, 2016 10:22 PM
  • User2122 posted

    @Matthew.4307

    Thanks for letting me know. I'll be working on that later this spring.

    Friday, March 18, 2016 11:04 PM
  • User2122 posted

    @AlanSpires -

    In your example, are you using a ListView or a StackLayout in a ScrollView?

    Friday, March 18, 2016 11:05 PM
  • User1884 posted

    Listview with item template selector for left and right cells

    Friday, March 18, 2016 11:10 PM
  • User2122 posted

    @AlanSpires , can you send me a copy of the template?

    Friday, March 18, 2016 11:11 PM
  • User1884 posted

    The template selector is nothing special. To send you the cells would be a lil tricky with the dependencies and what not.

    Friday, March 18, 2016 11:15 PM
  • User1884 posted

    I emailed you the cell, should be able to strip out the dependencies without a issue

    Friday, March 18, 2016 11:19 PM
  • User2122 posted

    Got it.

    Friday, March 18, 2016 11:19 PM
  • User2122 posted

    @AlanSpires, I've updated the Nuget package to 0.9.10.1 with what I believe is a fix (or at least a fix to the problem I could create). Also, I've updated the github demo (https://github.com/baskren/Forms9PatchDemo) to include a mockup of a chat app using a nine-patch image as the background for a Forms9Patch.ContentView inside of cells in a Xamarin.Forms.ListView.

    Monday, March 21, 2016 2:55 PM
  • User130667 posted

    First, nice package! However I'm running into an issue with referencing a 9patch image twice on Android (haven't tested iOS) by calling Forms9Patch.ImageSource.FromResource. The second time I call the graphic, the image seems to just stretch the image, ignoring the 9patches. Any chance the cached image from the "FromResource" is stripping the 9patch markings?

    Running Forms9Patch version 0.9.10.3 Also forms9patch.com seems to be down. Thanks!

    Thursday, March 24, 2016 2:01 AM
  • User130667 posted

    Here is the issue I'm running into and below is the code that I'm using in a simple XF Portable Project

    public App()
    {
        MainPage = new ContentPage
        {
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    CreateBar(0.5),
                    CreateBar(0.75),
                    CreateBar(0.65)
                }
            }
        };
    }
    
    private View CreateBar(double value)
    {
        AbsoluteLayout layout = new AbsoluteLayout() { BackgroundColor = Color.FromHex("#881f29") };
        var whiteBar = new Forms9Patch.Image() { Source = Forms9Patch.ImageSource.FromMultiResource("_9PatchTest.Resources.WhiteBar"), Fill = Forms9Patch.Fill.Fill };
        layout.Children.Add(whiteBar, new Rectangle(0, 0.5, value, 1), AbsoluteLayoutFlags.All);
        layout.HeightRequest = 120;
        return layout;
    }
    

    The rest is just the standard template code for a portable project. As you can see, one time, it seems to properly do stretch according to the 9patch, but every other time it appears to fail. I've also tried Source = ImageSource.FromResource("_9PatchTest.Resources.WhiteBar.9.png") to identical results

    Thursday, March 24, 2016 9:40 AM
  • User2122 posted

    @Everett -

    First, thanks for trying out Forms9Patch! I've got a lot of myself in it so it means a lot to me when someone sees value in it.

    What has happened is you've tried using Forms9Patch without a valid license key. When that happens, Forms9Patch will continue to work BUT it will only do it's image manipulations or caching on the first image presented to it. After that, it falls back to Xamarin.Forms.Image (which gives the results you see).

    The fix? Either get a valid license key or change your app name (temporarily) to Forms9PatchDemo (see instructions in the FAQ section of Forms9Patch.com on how to do this).

    And thanks again for giving Forms9Patch a try!

    Ben

    Thursday, March 24, 2016 12:09 PM
  • User2122 posted

    I've just updated the ChatListView demo to use the new (as of Xamarin Forms 2.1) DataTemplateSelector approach to dynamically selecting the appropriate template for a ListView. Here are some screen shots of the demo in action:

    iOS ChatListView Android ChatListView

    Thursday, March 24, 2016 7:54 PM
  • User34556 posted

    Hi Ben,

    your addition of the two Popup types looks really great! I'd love to use the lib in my current project, because my customer wants me to implement context menus for the cells in a ListView - which I bet is a royal pain to implement from scratch, especially given the complex view structure of my app.

    And that view structure is most likely the cause of the problem I'm facing: I can't get the BubblePopup to display.

    To be exact, I did manage to display it inside a rather simple page of my app: The target for the popup is a Button inside a ContentPage inside a NavigationPage. That works well. But the structure of the page I actually want to display the popup in is:

    A ListView inside a ContentPage inside a NavigationPage inside a MasterDetailPage inside a TabbedPage.

    And the goal is to use one of the cells inside the ListView as the target for the popup. So far I've tried creating and showing the BubblePopup without passing a host Page and also passing the ListView's parent ContentView to the popup. Unfortunately, nothing has worked so far. Neither the popup nor its background shroud will display.

    Have you got any hints for me how I need to create and configure the popup so it's properly displayed? Can it handle a Page structure as complex as mine at all?

    Currently my code for displaying the popup looks like this:

            public void BubblePopup (VisualElement origin, Page parentPage = null)
            {
                var hostPage = parentPage ?? Application.Current.MainPage;
    
                var popup = new Forms9Patch.BubblePopup(origin, parentPage) {
                    PointerDirection = Forms9Patch.PointerDirection.Vertical,
                    Content = new StackLayout {
                        Children = {
                            new Label { Text = "iGudeWie" }
                        }
                    }
                };
                popup.IsVisible = true;
            }
    

    The page I'm passing is the ListView's ContentPage.

    Tuesday, April 5, 2016 2:22 PM
  • User2122 posted

    @MichaelSattler ,

    It should be able to handle the complex page structure (I've been testing it against structures as complex). Assuming that is the case, read on ...

    I may be off base but I'm wondering if it has something to do with the VisualElement you are passing to it. If the element is as large as the page (or close to it), then it will have no choice but to render itself off the page. A good test would be to try your BubblePopup with a PointerDirection.None. If I remember correctly, that will effectively make it act like a ModalPopup. If that works, then it is an issue of not having enough room to render.

    Something else you may have already considered. If you're wanting to point to a cell (or a VisualElement in a cell) in the ListView, it's pretty tough to get a VisualElement for a ListView cell or item. This is one of a few actions I'm off making easier for myself in a Drag and Drop listview that I'm building. Effectively, what I'm doing is adding a weak reference to the VisualElement that is generated for the cell's content in the ListView's DataTemplateSelector. I do this in the class(es) that will be the cell's content by setting this weak reference when OnContextChanged is called and unsetting it when OnPropertyChanging for the BindableObject.BindingContextProperty property is called. This means, when the cell is selected, ListView gives me the selected item which in turn I use to look up the cell's content's VisualElement. Once I have that VisualElement, I can set it as the target for BubblePopup.

    Sort of off topic, if you don't set BubblePopup's hostPage attribute, it will do exactly what you're doing in your code: set the hostPage to Application.Current.MainPage.

    Again, I may have completely misunderstood what you are passing to BubblePopup's target parameter. If that's the case, take a moment to give me a better picture of what kind of element you're using as the target.

    Ben

    Tuesday, April 5, 2016 3:34 PM
  • User34556 posted

    @BuildCalc

    Thanks for your response!

    My intention was to use "Vertical" as the pointer direction, as usually any cell in a list would always have some space above or below it. I also tried setting the pointer direction to "None" and not specifying a target view, but that didn't help either. I even tried using the ModalPopup instead, but that also didn't work (it did on the "rather simple page" I mentioned, however).

    Can you tell me a bit about what Page or View the popups attach to? I have a strong suspicion that one of the numerous custom renderers in my project is killing the popups (our customers want practically any view and layout customized in some way - don't ask why we went with XForms in the first place).

    Wednesday, April 6, 2016 8:18 AM
  • User2122 posted

    @MichaelSattler

    Can you tell me a bit about what Page or View the popups attach to? The popups attach themselves to all of the stock Xamarin Forms pages (CarouselPage, MasterDetailPage, NavigationPage, Page, and TabbedPage). I just realized that TemplatedPage is missing (I'll fix that in the next release). They attach at the native renderer level, not the PCL element level.

    I have a strong suspicion that one of the numerous custom renderers in my project is killing the popups ... Since ModalPopup doesn't work as well, this appears to be a likely hypothesis. Those renderers could be disconnecting the connection of the Forms9Patch popups to the page renderers.

    If your hypothesis is correct, additions to Forms 2.1 may give me a path to address this. Before investing a great deal of time into this, it would be good to know that this is the root cause. Rather than continuing to go back and forth, would you be willing to do a screen share session so I can get a much better feel for your application?

    Wednesday, April 6, 2016 12:07 PM
  • User34556 posted

    @BuildCalc

    Yup, seems my hypothesis was indeed correct. I just tried disabling the custom renderer for my app's main page, and - tadah! - the ModalPopup/BubblePopup appeared.

    Unfortunately, for me this means I can't use your lib, because I can't get rid of our own custom renderers. Which is a real bummer, because I really like your lib's API and the options it provides. But I'll definitely keep it in mind for future projects!

    Side note: Attaching the BubblePopup to a ViewCell was actually pretty easy. I just needed to pass the ViewCell's View property to the BubblePopup as the target to display the popup next to the cell.

    Wednesday, April 6, 2016 12:35 PM
  • User2122 posted

    @MichaelSattler

    Thanks for confirming your hypothesis. I'm going to work on changing how the popups bind to the renderers and will let you know when the update is available. I would greatly appreciate it if you could test it then.

    Wednesday, April 6, 2016 1:22 PM
  • User34556 posted

    I hope I'll find some time to test the update when it's ready. Thanks for your great support!

    Wednesday, April 6, 2016 1:26 PM
  • User2122 posted

    @MichaelSattler

    Looks like the approach I had in mind won't work at this time. If at sometime in the future it does, I'll update the package.

    Wednesday, April 6, 2016 3:29 PM
  • User2122 posted

    @MichaelSattler

    I have a suggestion for you that might work. In your custom page renderers, give this a try (the following is for your version of NavigationRenderer, you would alter appropriately for your other renderers):

    ``` using Forms9Patch.iOS;

    namespace YourCustomRendererNameSpace.iOS { public class YourCustomNavigationRenderer : Xamarin.Forms.Platform.iOS.NavigationRenderer { protected override void OnElementChanged (VisualElementChangedEventArgs e) { base.OnElementChanged (e); this.PageRendererExtensionOnElementChanged (e); }

        protected override void Dispose (bool disposing)
        {
            this.PageRendererExtensionDispose (disposing);
            base.Dispose (disposing);
        }
    }
    

    }

    ```

    Wednesday, April 6, 2016 3:37 PM
  • User34556 posted

    @BuildCalc

    Which class or extension do the PageRendererExtensionOnElementChanged and PageRendererExtensionDispose methods belong to?

    My application's root page is a TabbedPage, so I'll have to change the TabbedRenderer for this...

    Thursday, April 7, 2016 6:18 AM
  • User2122 posted

    Those two methods are both in Forms9Patch.iOS and Forms9Patch.Droid. You would use them in the iOS and Android versions of your custom TabbedRenderer - which means you will have to: - add a reference to Forms9Patch.iOS in your TabbedRenderer's iOS project - add a reference to Forms9Patch.Droid in your TabbedRenderer's Droid project - add a using Forms9Patch.iOS; statement to the beginning of your TabbedRenderer's iOS file - add a using Forms9Patch.Droid; statement to the beginning of your TabbedRenderer's Android file

    Thursday, April 7, 2016 11:01 AM
  • User2122 posted

    iOS:

    ``` using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; using Forms9Patch.iOS;

    namespace YOUR NAME SPACE.iOS { public class TabbedRenderer : Xamarin.Forms.Platform.iOS.TabbedRenderer { protected override void OnElementChanged (VisualElementChangedEventArgs e) { base.OnElementChanged (e); this.PageRendererExtensionOnElementChanged (e); }

        protected override void Dispose (bool disposing)
        {
            this.PageRendererExtensionDispose (disposing);
            base.Dispose (disposing);
        }
    }
    

    }

    ```

    Android:

    ``` using Xamarin.Forms; using Xamarin.Forms.Platform.Android; using Forms9Patch.Droid

    namespace YOUR NAME SPACE.Droid { internal class TabbedRenderer : Xamarin.Forms.Platform.Android.TabbedRenderer { protected override void OnElementChanged (ElementChangedEventArgs e) { base.OnElementChanged (e); this.PageRendererExtensionOnElementChanged (new VisualElementChangedEventArgs(e.OldElement, e.NewElement)); }

        protected override void Dispose (bool disposing)
        {
            this.PageRendererExtensionDispose (disposing);
            base.Dispose (disposing);
        }
    }
    

    }

    ```

    Thursday, April 7, 2016 11:04 AM
  • User166393 posted

    @BuildCalc Will you guys support winrt and windows phone also?

    Thursday, April 7, 2016 11:47 AM
  • User139758 posted

    @BuildCalc

    Maybe you could use an Effect attached to the Page's? You could call these two methods in the Effect instead of the renderer?

    Thursday, April 7, 2016 11:53 AM
  • User2122 posted

    @TobiasSchulz.9796

    Funny you would suggest that! See this Xamarin Forms discussion. The net is I had started to but something was not behaving in my Xamarin environment. Whatever it was, I had my fooled in believing PlatformEffects don't work on Page elements. Now that I'm passed that, I will start refactoring.

    Thursday, April 7, 2016 12:07 PM
  • User2122 posted

    @Maharshi.5212

    Yes, I will be working on it later this spring.

    Thursday, April 7, 2016 12:08 PM
  • User174229 posted

    I have downloaded the code and bubble works fine, but when I copied the ChatListPage in my cs file (I copied the complete file and pasted it message.cs and Replaced the class name and constructor to Message and also created one page ImageCircle),

    But now thing is "DataTemplateSelector" throwing error.

    Can you help me on this why its throwing error when I included it in my file.

    Thursday, April 7, 2016 1:39 PM
  • User2122 posted

    @Bikash00789

    Perhaps I could if I had much more information. A sample project via Github would be best. Sample code posted in a response here might still be helpful.

    Thursday, April 7, 2016 1:43 PM
  • User2122 posted

    @TobiasSchulz.9796 -

    It appears that PlatformEffects don't work on Page elements on iOS (but do on Android). You can see this sample project to see what I mean.

    Thursday, April 7, 2016 2:30 PM
  • User2122 posted

    @TobiasSchulz.9796 -

    Looks like the root cause has something to do with Page.effectControlProvider not getting set on iOS (but is on Android). I've updated the sample project to illustrate this.

    Thursday, April 7, 2016 2:56 PM
  • User34556 posted

    @BuildCalc Sorry for taking so long to get back to you. I tried out the changes you posted yesterday, and now I can see the popups, even with my custom renderer.

    Friday, April 8, 2016 12:05 PM
  • User174229 posted

    @Ben Askren: I do not have GitHub ac can I upload zip file here...

    Monday, April 11, 2016 6:52 AM
  • User2122 posted

    @MichaelSattler

    This is really good news - thanks for trying the code out! This means that, once Xamarin fixes the bug where PlatformEffects are not attaching to Page elements in iOS, I will be able to modify Forms9Patch so the extra steps you took won't be necessary. I'll keep the PageRendererExtensionOnElementChanged and PageRendererExtensionDispose extensions public so nothing will break.

    Monday, April 11, 2016 12:18 PM
  • User2122 posted

    @JSparrow -

    Please take two minutes to get yourself a free Github account. Really worth the trouble.

    Monday, April 11, 2016 12:19 PM
  • User2122 posted

    New Feature Announcement

    Forms9Patch now includes two new Features for its Label, MaterialButton, Segment, and ImageButtonState elements: - Text Formatting via HTML Markup - Easy, PCL, Custom Font Management

    The new HTML Markup Text Formatting ability gives you the following subset of HTML tags to in-line format your text.

    • <big> Big
    • <b> Bold
    • <del> Delete
    • <em> Emphesis
    • <font> Font. Attributes:
      • face: font family (supports native, "Monospace", "San-serif", "Serif", and Embedded Resource custom fonts)
      • size: font size (in "px", "em", and "%" units, HTML 1-7 unitless, HTML relative, and HTML named sizes )
      • color: font color (in rgb, rgba, hex, and HTML named colors)
    • <ins> Insert
    • <i> Italic
    • <pre> Prefomatted (Monospace font with white space preserved)
    • <s> Stikethrough
    • <small> Small
    • <strike> Strikethrough
    • <strong> Strong
    • <sub> Subscript
    • <sup> Superscript
    • <tt> Teletype
    • <u> Underline

    Additionally, it provides the following style attributes, which can be used with any tag (even those not shown above):

    • style: Style applied within tag limits. Parameters:
      • background-color: Background color. (in rgb, rgba, hex, and HTML named colors)
      • color: Font (foreground) color. (in rgb, rgba, hex, and HTML named colors)
      • font-family: Font family (supports native, "Monospace", "San-serif", "Serif", and Embedded Resource custom fonts)
      • font-size: font size (in "px", "em", and "%" units, HTML 1-7 unitless, HTML relative, and HTML named sizes )
      • font-weight: Set to bold to apply bold to the text.  Only bold is supported at this time and only on fonts there a bold subset is available.  It is recommended to use the <b> tag instead.
      • font-style: Set to italic to apply italics formatting to the text. Only italic is supported at this time and only on fonts where an italic subset is available.  It is recommended to use the <i> tag instead.

    The new Custom Font Management takes out all of the platform specific work Xamarin requires to use custom fonts. Just add your font as an Embedded Resource to your PCL project and, when you need it, refer to it by its Resource ID when setting the FontFamily property of a Forms9Patch element or, in HTML, a FontFamliy or Face attribute.

    In concert with 3rd party fonts, like Google's Material Icon font, this means Forms9Patch make it a lot easier to craft your buttons and labels.

    There are lots of examples in the demo app and you can learn a lot more by visiting the Forms9Patch home page at http://Forms9Patch.com.

    As an example, here some sample code for a number of labels: ``` using Xamarin.Forms;

    namespace Forms9PatchDemo { public class HtmlLabelPage : ContentPage { public HtmlLabelPage () { Padding = new Thickness (5, 20, 5, 5); Content = new ScrollView { Content = new StackLayout { Children = { new Label { Text = "Hello HtmlLabelPage" },

                        new Forms9Patch.Label { HtmlText =  "<b>\nEMBEDDED (resource) CUSTOM FONT:</b>"},
                        new Forms9Patch.Label { 
                            Text = "????????",
                            FontFamily = "Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf",
                        },
    
                        new Forms9Patch.Label { HtmlText =  "<b>\nSUPPORTED HTML TAGS:</b>" },
                        new Forms9Patch.Label { HtmlText =  "plain: no tags"},
                        new Forms9Patch.Label { HtmlText =  "&lt;b&gt;: <b>Bold</b> plain"},
    
                        new Forms9Patch.Label { 
                            HtmlText =  "&lt;Bold&gt;: <b>Bold</b> w/ serif italic serif base font",
                            FontFamily = "Serif",
                            FontAttributes = FontAttributes.Italic,
                            TextColor = Color.Blue,
                        },
    
                        new Forms9Patch.Label { HtmlText =  "&lt;strong&gt;: <strong>strong</strong> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;i&gt;: <i>Italic</i> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;em&gt;: <em>emphesis</em> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;b&gt;&lt;i&gt;: <b><i>Bold+Italic</i></b> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;sub&gt;: H<sub>2</sub>0 H20 plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;sup&gt;: 42<sup>2</sup> 42² plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;u&gt;: <u>underlined</u> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;ins&gt;: <ins>inserted</ins> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font color=&quot;blue&quot;&gt;: <font color=\"blue\">Blue</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font color=&quot;#FF0000&quot;&gt;: <font color=\"#FF0000\">Red</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font color=&quot;rgb(0,255,0)&quot;&gt;: <font color=\"rgb(0,255,0)\">Green</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;1&quot;&gt;: <font size=\"1\">size 1</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;2&quot;&gt;: <font size=\"2\">size 2</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;3&quot;&gt;: <font size=\"3\">size 3</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;4&quot;&gt;: <font size=\"4\">size 4</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;5&quot;&gt;: <font size=\"5\">size 5</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;6&quot;&gt;: <font size=\"6\">size 6</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font size=&quot;7&quot;&gt;: <font size=\"7\">size 7</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font face=&quot;Monospace&quot;&gt;: <font face=\"Monospace\">Monspace</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font face=&quot;Serif&quot;&gt;: <font face=\"Serif\">Serif</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font face=&quot;Sans-serif&quot;&gt;: <font face=\"Sans-serif\">Sans-serif</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;font face=(resource)&gt;: <font face=\"Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\">????????</font> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;pre&gt;: <pre>preformatted  text</pre> plain  \ttext"},
                        new Forms9Patch.Label { HtmlText =  "&lt;tt&gt;: <tt>teletype</tt> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;strike&gt;: <strike>strikethrough</strike> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;s&gt;: <s>strikethrough</s> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;del&gt;: <del>deleted text</del> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;big&gt;: <big>BIG text</big> plain"},
                        new Forms9Patch.Label { HtmlText =  "&lt;small&gt;: <small>SMALL text</small> plain"},
    
                        new Forms9Patch.Label { HtmlText =  "\n<b>SUPPORTTED HTML ATTRIBUTES:</b>"},
                        new Forms9Patch.Label { HtmlText =  "background-color: <div style=\"background-color:LightGrey\">LightGrey background</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "color: <div style=\"color:Sienna\">Sienna Text</div> plain"},
    
                        new Forms9Patch.Label { HtmlText =  "font-family (resource): <div style=\"font-family:Forms9PatchDemo.Resources.Fonts.MaterialIcons-Regular.ttf\">????????</div> plain"},
    
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:50%\">50% Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:8.5px\">8.5px Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:100%\">100% Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:17px\">17px Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:200%\">200% Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-size: <div style=\"font-size:34px\">34px Text</div> plain"},
                        new Forms9Patch.Label { HtmlText =  "font-weight: <div style=\"font-weight:Bold;font-style:Italic\">Bold+Italic Text</div> plain"},
    
    
                    }
                }
            };
        }
    }
    

    } ```

    And the resulting screen shots:

    | Apple | Android | | ------ | -------- | | HtmlLabelApple1 | HtmlLabelAndroid1 | | HtmlLabelApple2 | HtmlLabelAndroid2 | | HtmlLabelApple3 | HtmlLabelAndroid3 |

    Friday, May 6, 2016 8:01 PM
  • User236812 posted

    Hello @BuildCalc,

    I used your library in my project. Its really great library and thanks for that.

    But I have a small issue related to 9 patched images on iOS.

    I have a test projects created in Xamarin.Forms Apps. When, I build and run it on android, it works perfectly. But Same code I run on iOS, it don’t works. The image loads and shows properly, honour its CapInsets on Android, but on iOS the image loads but don’t honour its CapInsets.

    I use XAML for layout, and below is my sample XAML code.

    <?xml version="1.0" encoding="utf-8"?>? <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" ?
    xmlns:local="clr-namespace:Test9Patch" ?
    x:Class="Test9Patch.Test9PatchPage"?
    xmlns:Forms9Patch="clr-namespace:Forms9Patch;assembly=Forms9Patch">??
    <StackLayout HorizontalOptions="Center" VerticalOptions="Center"> ? <Label Text="Welcome to Xamarin Forms!" VerticalOptions="Center" HorizontalOptions="Center" TextColor="Black" /> ? <Grid WidthRequest="530"> ? <Forms9Patch:Image Source="{local:ImageMultiResource Test9Patch.Resources.button_login}" CapInsets="12,12,12,12" /> <!-- CapInsets="12,12,12,12" --> ? </Grid> ? </StackLayout> ?</ContentPage>??

    Please remember that, this code works on Android but not on iOS. I just need what specific thing i need to do to solve this. I need your help.

    Saturday, June 25, 2016 7:49 AM
  • User2122 posted

    @NealLea, Thanks for giving me a chance to help. I will take a look at this no later than Monday and see what can be done.

    Saturday, June 25, 2016 11:44 AM
  • User236812 posted

    @BuildCalc, Thanks for your reply. I would like you to have a look into issue and let me know the solution. :)

    Monday, June 27, 2016 12:33 PM
  • User2122 posted

    @NealLea ,

    I'm working on at right now. I believe I've found the root cause. Should have an update this afternoon if all goes well.

    Monday, June 27, 2016 12:34 PM
  • User2122 posted

    @NealLea ,

    I believe I have the now fixed issue you found and have pushed an update (0.9.11.2) to Nuget. I've added the "Unrequested size, CapsInset Test" XAML test to the demo app to illustrate this in action. Please take a moment to update your packages and let me know if this addresses the issue as it has manifested itself in your application.

    And thank you again for giving me a change to address this - and thank you for bringing it to my attention.

    Monday, June 27, 2016 2:37 PM
  • User2122 posted

    New Feature Announcement

    After three weeks of work, I've been able to enhance the Forms9Patch library's Label element to have 6 different modes of autofitting/autoscaling/autosizing. This works with plain and HTML formatted text and with Head, Mid and Tail ellipses truncation. Three of the modes are for when the Label's bounds are imposed (by HeightRequest, WidthRequest or it's content is smaller than its parent layout) and the other three are for when its width has been imposed but the height has not.

    By default, if you set its Lines property to zero, it will either scale the font to fit the bounds (Bounds imposed) or scale the height of the Label (Width imposed).

    imposed Bounds | imposed Width ------------------- | ------------------ imposed bounds, Lines=0 | imposed width, Lines=0

    If the Lines property is non-zero and you set the Fit property to LabelFit.Width, it will shrink the font size down from FontSize its until its content width fits on Lines lines. The shrinking is limited to MinFontSize, at which point it will truncate.

    imposed Bounds | imposed Width ------------------- | ------------------ imposed bounds, Lines!=0, Fit=LabelFit.Width | imposed width, Lines!=0, Fit=LabelFit.Width

    If the Lines property is non-zero and you set the Fit property to LabelFit.Lines, it will either scale the font to fit Lines lines in the imposed Height (Bounds imposed) or scale the Height to match Lines lines. If the text doesn't fit in Lines lines, it will truncate.

    imposed Bounds | imposed Width ------------------- | ------------------ imposed bounds, Lines!=0, Fit=LabelFit.Lines | imposed width, Lines!=0, Fit=LabelFit.Lines

    You can try it out in the demo app, available at https://github.com/baskren/Forms9PatchDemo and learn a lot more about how to use it and what else it has at http://Forms9Patch.com/ Now I back to working on the app that led me to work on Forms9Patch in the first place!

    Monday, July 18, 2016 2:42 PM
  • User2122 posted

    FYI: Just updated to 0.9.13.2. This build includes:

    • Enhanced:
      • Built to Android API 15 (rather than API 16)
      • Added IsElliptical to layouts and MaterialButton to make outline and fill elliptical rather than rectangular.
    • Fixed:
      • Opacity property of Image is now supported.
      • HtmlText property values with HTML font-size attributes that have decimal values will gracefully fail to the truncated integer values. Root cause appears to be a Xamarin.iOS bug (https://bugzilla.xamarin.com/show_bug.cgi?id=44385)
    • Changed:
      • StickyBehavior property of buttons has been renamed ToggleBehvior and (for MaterialSegmentedControl it has been changed to GroupToggleBehavior)
    Thursday, September 15, 2016 8:49 PM
  • User255419 posted

    Just a question. I'm using Forms9Patch to display images in my ViewList.ImageCell by using binding on ImageSource. However I cannot get it to work correctly.

    This is my class with setting properties for binding

        namespace MyApp
        {
            [ImplementPropertyChanged]
            public class Navigation
            {
                public string Title { get; set; }
                public string Description { get; set; }
                public ImageSource Thumbnail { get; set; }
            }
    
        }
    
    
    
    
               NavigationList = new List<Navigation>
                {
                    new Navigation { Title = "Evacuation", Description="Begin or manage an Evacuation", Thumbnail = Forms9Patch.ImageSource.FromMultiResource("MyApp.Resources.fireevac.png")},
                    new Navigation { Title = "Locations", Description="Manage employee locations", Thumbnail = Forms9Patch.ImageSource.FromMultiResource("MyApp.Resources.locations.jpg")},
                };
    

    And this is my XAML

              <ListView 
                ItemsSource="{Binding NavigationList}">
                <!--ItemSelected="OnItemSelected">-->
                <ListView.ItemTemplate>
                  <DataTemplate>
                    <ImageCell Text="{Binding Title}"
                               Detail="{Binding Description}"
                               ImageSource="{Binding Thumbnail}"
                               DetailColor="White"/>
                  </DataTemplate>
                </ListView.ItemTemplate>
              </ListView>
    

    What am I doing wrong?

    Monday, September 26, 2016 8:34 AM
  • User2122 posted

    @WojciechBoczarski - There is just a bit too much missing in your code sample for me to replicate the issue you are seeing. Could you make a sample project (you have most of what you would need in the above code) that replicates the issue and post it on GitHub or BitBucket? Doing so would allow me to help and allow others to benefit from our efforts as well.

    Monday, September 26, 2016 12:44 PM
  • User28517 posted

    Hi Ben,

    I found a small issue in the ModalPopup.

    var popup = new ModalPopup(); popup.Content = new StackLayout(); .... .... popup.BindingContext = new ViewModel();

    In the above code. When setting the BindingContext of the ModalPopup to ViewModel, the Content.BindingContext is set to the ModalPopup itself, not the ViewModel. This is the workaround that I came up with.

    var popup = new ModalPopup(); popup.Content = new StackLayout(); ..... ..... popup.Content.BindingContext = new ViewModel();

    I'm not sure if this is the correct behaviour

    Friday, December 2, 2016 5:28 AM
  • User2122 posted

    @tomnuen -

    It might be the correct behavior. I'm on the road through the weekend but I'll take a closer look when I return.

    • Ben
    Friday, December 2, 2016 12:26 PM
  • User236402 posted

    @BuildCalc Can you please provide me some samples for Modal and Bubble Popups with Xaml code (for the controls and binding).

    Thanks.

    Friday, January 27, 2017 9:05 PM
  • User240190 posted

    @BuildCalc @BenAskren
    I'm very new to Xamarin.Forms. In this below url I found a License key for Forms9Patch ("8HY9-P5V6-J9WA-B3G8-BA8E-ERSA-JRKV-XTHE-79K6-YPY2-YRWX-Y5CW-RA59") and it works only for the project named as "MyDemoApp". If I have other name for my project (for testing and understanding the Forms9Patch purpose only) is there any other trail license key for this. And also I didn't find any sample resources with Xaml. Could you please suggest me and please provide me some samples please.

    Friday, January 27, 2017 10:19 PM
  • User280521 posted

    Hi, Amazing control set. Specially the BubblePopup. You have at the moment BubblePopup bound either to VisualElement or null. We would like to use it with toolbarItems. It is displayed in regards to where the toolbar item is, which is currently not possible because the toolbar items does not inherit from VisualElement! Also It would be interesting if the position can somehow be specified, say for example I have a map in my page and user long presses somewhere, I know the location of the tap, I want to display the bubblePopup in that location with some action buttons.. Is there a way somehow to achieve what we want!! Or implemented in near future? Please help Regards, Murshed

    Wednesday, February 1, 2017 12:26 PM
  • User2122 posted

    @SyedMoshiurMurshed, thanks for the feedback. I've looked into this and it would not be trivial. At the moment, I don't have the bandwidth to do this so I must apologize that it won't happen anytime soon.

    Thursday, February 2, 2017 12:21 PM
  • User2122 posted

    @Guptha, @SJ-87

    The demo app name and key make up the mechanism to allow beta testing.

    I'm about to step out on a limb here (so I invite anyone with a better understanding of Xamarin's XAML to correct me). Forms9Patch popups, by their nature, are not children of a page in the classical sense. This is because they need to cross page boundaries when presented over a MasterDetailPage.

    If anyone reading this is very knowledgeable about Xamarin XAML, I have a question: Is it possible to make a .xaml + .xaml.cs pair for a Xamarin.Forms Layout (instead of a Xamarin.Forms Page)?

    Thursday, February 16, 2017 12:53 PM
  • User2122 posted

    Forms9Patch version 0.10.1.0 released

    Performance

    This version has LOTS of new features. Some of the most important changes are for performance. Specifically:

    • Forms9Patch.Label checks for and ignores redundant layout cycles
    • Forms9Patch layouts now have the bool IgnoreChildren property. Setting this property to true will cause the layout in question to ignore InvalidateMeasure or layout changes on its children. Why would you want this? Let's say you have a grid view and none of the rows and columns are GridUnitType.Auto. In other words, your grid cell sizes should never change in response to a change in a child element. Set IgnoreChildren to true and now you greatly reduced the number of measure/layout calls up and down the view hierarchy with (in this case) no ill effects. Please note: this is a "running with scissors" feature. Use with caution.
    • Added the Retain property to the popups. The purpose of this property is to keep a popup (and its content) on the view stack after the popup has been hidden. This means that the popup and its children will not need to be re-rendered (sometimes a painful process on Android) when it is presented again.

    more tags in HTML markup

    Another feature that has been requested a few times: support for the <a> tag in HtmlText properties. The demo app has an example of this in action. Just be sure to include an id and/or href attribute because <a> doesn't launch a browser window. Rather, it fires an ActionTagTapped event on your Forms9Patch.Label instance and passes id and href as strings.

    Also, I've added the <num> and <den> tag as slightly different versions of <sup> and <sub>.

    Convenience popups

    The Toast, TargetedToast, PermissionPopup and ActivityIndicatorPopup are all meant to make common tasks much easier.

    Support for using Icon Fonts in lieu of ImageSource

    The MaterialButton and MaterialSegmentedControl now support using HTML markup text as an alternative to ImageSource for the button's icon. The IconText property is for this purpose. See Forms9Patch.com for an example.

    Extensions

    A bunch of extensions you night find useful:

    • static Color RgbBlend(this Color c, Color c2, double percent) usage: blend = c.RgbBlend(c2, percent) will return the color percent between c and c2.
    • static Color WithAlpha(this Color c, double alpha) usage: alphaColor = c.WithAlpha(c, alpha) will return a modified version of color c where the opacity has been set to alpha.
    • static bool CanPrint(this WebView webview) will return if you can print the contents of a Xamarin.Forms.WebView.
    • If CanPrint returns true, you can use static void Print(this WebView webview, string jobname) to print the contents of a Xamarin.Forms.WebView.
    • Use static Color ToColor(this string s) to take a HTML color string and turn it to a Xamarin.Forms.Color.
    • Want to create an image of some HTML? Pass a HTML string to static void ToPng(this string html, string fileName, Action<string> onComplete) and it will pass the path to a PNG image of the HTML to the onComplete action. See Forms9Patch.com for an example.

    Services

    • Want to hide the on-screen keyboard? Call KeyboardService.Hide().
    • Want to be notified when the on-screen keyboard appears? Subscribe to the KeyboardService.Shown event.
    • Want to be notified when the on-screen keyboard disappears? Subscribe to the KeyboardService.Hidden event.
    • Want to make a system haptic feedback (sound/vibrate) to happen? Check out the HapticsService.Feedback method.

    ListView and SinglePicker

    These have actually been undocumented elements for quite a number of releases. However, I'm to the point where their interfaces have stabilized. Unfortunately, their Android performance still isn't good enough so I'm making them "alpha". If you're curious about them, let me know and I'll share more.

    More

    There are a few more new features and tweaks. Check out Forms9Patch.com to learn more.

    Thursday, February 16, 2017 1:35 PM
  • User2122 posted

    If anyone reading this is very knowledgeable about Xamarin XAML, I have a question: Is it possible to make a .xaml + .xaml.cs pair for a Xamarin.Forms Layout (instead of a Xamarin.Forms Page)?

    I'm an idiot! Yes, Xamarin Studio makes this easy because "Forms ContentView XAML" is an option when you do a "File New...".

    @Guptha, @SJ-87, To further try to answer your question: You still can't specify a Forms9Patch popup via XAML (again, because it isn't a child of a page or view) but you can specify the Content of a Forms9Patch popup in XAML. Then, in your page or views code behind you can instantiate and present your popup.

    Thursday, February 16, 2017 3:35 PM
  • User2122 posted

    Forms9Patch version 0.10.2 now available

    Now supports Shared Library Projects

    I got a question this morning: does Forms9Patch support Shared Library projects? I had no idea so I tried it. Sure enough, it (almost) does. Everything works except reading Embedded Resource font files (and that caused things to crash). After some work, I'm proud to say version 0.10.2 now supports Shared Library projects!

    And, if you're curious about how such a project is put together, your can check out the Shared Library Forms9Patch demo app.

    Wednesday, February 22, 2017 7:14 PM
  • User290660 posted

    Hi, I am really interested in using your library. The first item I wanted to use is the ModalPopup but when I run it up on the iOS simulator I get this exception: System.MissingMemberException: FormsGestures: Failed to load IGestureService instance. It runs fine on the Android simulator and your demo app runs fine too! Not sure what I am doing wrong here, I have created a minimum reproducible project on BitBucket: https://bitbucket.org/glenr4/forms9patchbugdemo/overview

    Can you please help!

    Wednesday, March 22, 2017 12:48 AM
  • User2122 posted

    @GlenRutherford

    First, thanks for giving me a chance to help. You've stumbled upon the most common issue encountered by Forms9Patch users: Not initializing Forms9Patch. To fix it, you need to add the following to your Android project's MainActivity.cs immediately after global::Xamarin.Forms.Forms.Init(...).

    Forms9Patch.Droid.Settings.LicenseKey = "NZPK-RMP4-PJVV-Z7LP-78JF-GNXB-CDJZ-SRYA-BLR2-WBZC-G64K-QJZW-65DB";

    And, likewise, for your iOS project's AppDelegate.cs:

    Forms9Patch.iOS.Settings.LicenseKey = "NZPK-RMP4-PJVV-Z7LP-78JF-GNXB-CDJZ-SRYA-BLR2-WBZC-G64K-QJZW-65DB";

    Also, if you tripped over this problem, you'll very likely trip over other configuration issues as well. Please take a moment to go to http://Forms9Patch.com and review the instructions on "How do I configure my app name?" and "Is there a trial version?".

    Wednesday, March 22, 2017 12:31 PM
  • User290660 posted

    OK thanks for the advice. I thought that I would be immune to the trial restrictions as I'm not trying to use "HtmlText properties and the image manipulations". Anyway, I'll update my project and hopefully all will be good!

    Wednesday, March 22, 2017 10:30 PM
  • User290660 posted

    I've decided to buy a license but my App name will probably change between now and release (depending on what the client eventually decides to call it). Can it be updated later or is it fixed from now until the end of time?

    Wednesday, March 22, 2017 10:42 PM
  • User2122 posted

    @GlenRutherford , rather than buying a license (and if possible for business reasons), I would recommend naming your app Forms9PatchDemo during your early development. This would allow you to use the Forms9Patch demo license key and try out all of the Forms9Patch functionality.

    With that being said, I should note that most of the Forms9Patch features do not require a valid key (no kidding!). Setting the key (to a valid or invalid value) is required to assure all the dependencies are linked (which is the problem you ran into earlier).

    Lastly, if you do purchase a key and realize it isn't for the needed app name, just email me and we'll work it out.

    Thursday, March 23, 2017 12:50 AM
  • User290660 posted

    Cool, thanks.

    Thursday, March 23, 2017 9:31 PM
  • User28517 posted

    On iPhone 7 Plus, the Display.Scale method returns 1 (supposed to be 3). Correct me if I'm wrong, it must call UIScreen.MainScreen.Scale behind the scene. There is a property called UIScreen.MainScreen.NativeScale which returns the correct device scale (3). You might want to update your implementation if that is the case.

    Thursday, March 23, 2017 9:45 PM
  • User2122 posted

    @tomnuen - There may be a bug in play here but I have my doubts. I just ran the code on the emulator for the iPhone 7s Plus and, as it should, it returned 3 for Display.Scale. That being said, it will return the wrong value if you didn't call Forms9Patch.iOS.Settings.LicenseKey = "a_valid_or_invalid_license_key_here"; in your AppDelegate.cs file (right after global::Xamarin.Forms.Forms.Init(...).

    Friday, March 24, 2017 12:25 AM
  • User28517 posted

    @BuildCalc you're correct! I just gave Forms9Patch a try and didn't put in the license key.

    Thank you!

    Friday, March 24, 2017 12:36 AM
  • User297263 posted

    Hi @BuildCalc , need your help.. after getting a license the an error shows ..

    Position 6:16. Type ImageMultiResource not found in xmlns error : An item with the same key has already been added

    Wednesday, April 12, 2017 8:25 AM
  • User2122 posted

    @blendedcoffee , without seeing a lot more information I can only take a guess. Can't say enough about how important it is to stop and make time to construct a good question.

    The biggest clue is Type ImageMultiResource not found in xmlns which, in english, means the ImageMultiResource IMarkupExtension is not visible to your XAML file. Why is that? My guess would be you're either missing either a xmlns:local= attribute in your XAML's root tag (that would give it visibility to the namespace & assembly that has the ImageMultiResource IMarkupExtension -or- you don't have the ImageMultiResource IMarkExtension in that namespace & assembly.

    Or, it could be something else. The error: An item with the same key has already been added doesn't help a lot and could be a sign that there's something else going on here.

    In other words, I've probably spent more time guessing than was spent constructing the question. If my guesses are not helpful, please try using Xamarin's bug writing guidelines as a template on how to ask for help.

    Wednesday, April 12, 2017 12:05 PM
  • User128353 posted

    With the latest 0.10.2.9 version of Forms9Patch, I'm getting the following error in the FormsPreviewer for Android:

    "Specified cast is not valid" Forms9Patch.Droid.LabelRenderer.OnElementChanged, line: 0

    The iOS previewer works fine.

    I'm also getting instances where labels are not autosizing and being cutoff on Android:

    ``` Fuschia #E5E5EA #000000

    <Color x:Key="PrimaryColor">#99242F</Color>
    <Color x:Key="SecondaryColor">#414042</Color>
    

    <Style x:Key="MainLabelStyle" TargetType="f9p:Label">
        <Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
        <Setter Property="HorizontalTextAlignment" Value="Center" />
        <Setter Property="Lines" Value="1" />
        <Setter Property="Fit" Value="Lines" />
        <!-- Fixes an issue on iPhone 7 Plus having the text wrap and cutoff on this style (it should be on one line and this fixes that -->
        <Setter Property="Margin" Value="1" />
    </Style>
    
    <Style x:Key="MainSubLabelStyle" TargetType="f9p:Label">
        <Setter Property="TextColor" Value="{DynamicResource SecondaryColor}" />
        <Setter Property="HorizontalTextAlignment" Value="Center" />
        <Setter Property="Lines" Value="1" />
        <Setter Property="Fit" Value="Lines" />
        <Setter Property="Margin" Value="1" />
    </Style>
    

    ```

    ```

               <Image Grid.Row="0" Source="resources.png" />
                <f9p:Label Grid.Row="1" Text="Existing Tips" Style="{StaticResource MainLabelStyle}" BackgroundColor="{StaticResource DebugBackgroundColor}" />
                <f9p:Label Grid.Row="2" Text="Existing Tips" Style="{StaticResource MainSubLabelStyle}" />
    
            </f9p:Grid>
    

    ```

    On Android:

    On iOS, it works if I set a Margin of 1 (shown in the style above).

    Thanks!!

    Wednesday, May 3, 2017 5:11 PM
  • User2122 posted

    @renzska --

    Can you send me a sample project that demonstrates what you're seeing? There are a lot of boundary conditions not covered in your sample code that may or may influence your results. A sample project would go a long way in helping me understand what you are seeing and why.

    -- Ben

    Wednesday, May 3, 2017 5:23 PM
  • User128353 posted

    @BuildCalc, I'll put one together and post it soon. Thanks!

    Wednesday, May 3, 2017 5:26 PM
  • User2122 posted

    @renzska: Looking forward to it.

    Wednesday, May 3, 2017 5:27 PM
  • User128353 posted

    I've attached the labeltest project.

    To be specific, I am using Visual Studio for Mac Preview 9 (7.0 build 2943). I also tested on Xamarin Studio 6.3 (build 864) with the same issue.

    So the two issues are:

    ``` On 0.10.2.9 version of Forms9Patch, I'm getting the following error in the FormsPreviewer for Android:

    "Specified cast is not valid" Forms9Patch.Droid.LabelRenderer.OnElementChanged, line: 0 ```

    On iOS and Android the labels are autofitting as I would expect. It is a possibility that it is my XAML causing the issues, but I'm unsure (this is with more testing). I was originally having iOS size correctly, but Android not resizing at all (which still may be the case in some scenarios.

    In my sample,

    I have modified it slightly so the bottom row of "buttons" tries Fit="None" and Fit="Width" insteand of Fit="Lines". You should be able to see this in the xaml. My goal is to have the labels autosize to the size of the grid as the device size gets larger, or shrink if it is smaller, and never have the text cutoff or go onto multiple lines. If you have any questions, let me know.

    Thanks for looking into this.

    Wednesday, May 3, 2017 7:19 PM
  • User128353 posted

    Looks like they just released Preview 10 of Visual Studio for Mac. I'll be updating to see if that changes anything.

    Wednesday, May 3, 2017 7:21 PM
  • User2122 posted

    @renzska --

    I've just submitted 0.10.2.10 with a work around for what appears to be a bug with XAML Previewer. After you update your Forms9Patch nuget package in your projects, you will need to restart Xamarin.Studio / VisualStudio.Mac and recompile your Android projects to take advantage of the updates.

    -- Ben

    Wednesday, May 3, 2017 8:56 PM
  • User2122 posted

    @renzska --

    Once you have verified that the XAML Previewer is working, the next question is how to accomplish your layout goals. The text in the sample app you've provided is wider than 1 line when on a phone in portrait orientation. As such, you can either:

    • unconstrain its height and set its Fit to LabelFit.None and its Lines=0
    • use LabelFit.Width and set the lines to something that will be adequate to contain your text
    • use LabelFit.Lines and set the font size to be small enough to contain our text

    I would highly recommend that you take a look at the Pages/LabelFitPage.cs and Pages/UnconstrainedLabelFitPage.cs examples in the demo app. Running the demo app and using these pages (Code/LabelFit and Code/Unimposed Height Label Fit) is a good way to determine what Fit, Lines, Alignments, and Truncation Modes you want to use in your application.

    -- Ben

    Wednesday, May 3, 2017 9:08 PM
  • User128353 posted

    @BuildCalc, the latest version fixed the Android Xamarin Forms Previewer. Thanks for that!

    On the sizing, my main goal is to have the text autofill the width and then go as tall as they can with the space given them. In this case, the label stretches to fill the grid row height and width. What settings would I need to have this happen?

    What's the outcome of each of the bullet points you mentioned above?

    Thanks again for your help!

    John

    Thursday, May 4, 2017 5:24 PM
  • User2122 posted

    @renzska --

    Assuming that you're putting each Label in a Frame and that Frame is in a cell of a Grid, I would start with the following settings:

    • HorizontalLayout = LayoutOptions.Fill
    • VeritcalLayout = LayoutOptions.Fill
    • Fit = Width
    • HorizontalTextAlignment = TextAlignment.Center
    • VerticalTextAlignment = TextAlignment.Center

    And you will want to set Lines, FontSize, MinFontSize, and LineBreakMode as a matter of taste. What I mean is, if your text is short and the FontSize is huge, it will fill the entire Frame with a large font text no matter the number of lines. The FontSize property sets the upper limit of the FontSize so you can use it to assure the text doesn't get too big. As the text gets longer and longer, it will first shrink the actual font size to fill the number of lines set by the Lines property and then continue to shrink to stay within the Frame and number of lines. This keeps happening until it gets to the size set by MinFontSize. Once it gets there, it will truncate the text by LineBreakMode setting.

    Friday, May 5, 2017 10:31 AM
  • User2122 posted

    @renzska -- I forgot to mention that I think the LabelFitPage in the demo app might be a great example of what you're seeking. Try the setting I mentioned above on that page and then shorten/lengthen the text and change the orientation to see how it responds.

    Friday, May 5, 2017 11:23 AM
  • User128353 posted

    @BuildCalc, thanks for the help and the great library!

    Tuesday, May 16, 2017 3:38 PM
  • User128353 posted

    @BuildCalc, Over the course of some changes to my mainpage which uses the autosizing label (and works very well, I might add), I've run into an issue where on Android devices, the labels render, but then disappear slightly after rendering. This occurs to random labels and at random times. I am using the Pixel 23 default Android emulator (it also occurs on my physical device (Samsung Galaxy S4). I believe it might be caused by the complexity of my XAML, because when I remove two header images, the issue does not repeat itself, however, I was hoping you could look into it and determine if there was something you could do within Forms9Patch to resolve the issue, even with the complex XAML form (or provide tips in changing my XAML to achieve the same result).

    I have purchased a license for the control. I have put a sample application project together that I'd like to send you for debugging purposes. I have sent it to the email address on your site with the subject "Forms9Patch: Renzska Forums Issue. If you could let me know if you received it and work through the issue via email (or here if preferred) it would be greatly appreciated as my deadline is coming very soon.

    Thanks,

    John

    Monday, June 26, 2017 5:13 PM
  • User2122 posted

    @renzska --

    I got your email. I'll be able to take a look at your layout in the morning. In the meantime, I wanted to say thanks for letting me know that you were able to work around the issue by using a Grid layout instead. For those reading this thread, I can't say enough about how much more efficient a Grid layout is than a nested StackLayout.

    -- Ben

    Monday, June 26, 2017 7:52 PM
  • User2122 posted

    Version 0.10.3.0 Now Available

    The primary change in 0.10.3.0 is an improvement to how the ImageButton, MaterialButton and MaterialSegmentedControl aligns text and icons. The changes are meant to give more control on how they are positioned and aligned. Changes include:

    • The Alignment property has been obsoleted in favor of the HorizontalTextAlignment and VeriticalTextAlignment properties.
    • ImageButton now responds to the Orientation property just as MaterialButton does.
    • MaterialSegmentedControl now has the IntraSegmentSpacing and IntraSegmentOrientation properties which mirror the behavior of the Spacing and Orientation properties of MaterialButton and ImageButton.

    Below are some gifs to illustrate these changes in action:

    MaterialButton and MaterialSegmentedController alignment and spacing

    ImageButton alignment and spacing

    Tuesday, June 27, 2017 8:50 PM
  • User2122 posted

    I recently saw a question on StackOverflow asking how to have a Label in Xamarin.Forms with a phone number and email link. In case you're interested, here is an example of how easy this is with Forms9Patch.

    using System;
    using Xamarin.Forms;
    namespace Forms9PatchDemo
    {
        public class LabelLink : ContentPage
        {
            public LabelLink()
            {
                var label = new Forms9Patch.Label
                {
                    HtmlText = "Contact us on <a id=\"phone\" href=\"tel:+353015546889\">015546889</a> or <a id=\"email\" href=\"mailto:email@hotmail.com\">email@hotmail.com</a>"
                };
                label.ActionTagTapped += (object sender, Forms9Patch.ActionTagEventArgs e) =>
                {
                    var id = e.Id;
                    var href = e.Href;
                    var uri = new Uri(e.Href);
                    Device.OpenUri(uri);
                };
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Label { Text = "Forms9Patch.Label.HtmlText <a> example" },
                        new BoxView { BackgroundColor = Color.Black, HeightRequest = 1 },
                        label
                    }
                };
            }
        }
    }
    

    Note that his example doesn't work on the iOS emulators because they don't support the tel: and mailto: schemas.

    I also have heard that this is going to be even easier with Xamarin.Forms 2.3.5 because its XAML will support the <CDATA> tag.

    Wednesday, July 5, 2017 12:28 PM
  • User328583 posted

    @BuildCalc Hi Ben, How to setup Forms9Patch with Prism ?

    Means, How can I set MainPage = Forms9Patch.RootPage.Create(new NavigationPage(new PopoverPage())); with Prism navigation ?

    Thursday, July 6, 2017 11:14 AM
  • User2122 posted

    @Hiran_Peiris

    What little I know about Prism makes me not sure how you would go about doing this but I have a guess that just might work. Assuming you setup the Prism Bootstrapper as follows ...

    public class App : Application
    {
         public App()
         {
             Bootstrapper bs = new Bootstrapper();
             bs.Run(this);
         }
    }
    

    You would insert Forms9Patch's RootPage into the page hierarchy as follows:

    public class App : Application
    {
         public App()
         {
             Bootstrapper bs = new Bootstrapper();
             bs.Run(this);
             var prismMainPage = MainPage;
             MainPage = Forms9Patch.RootPage.Create(prismMainPage);
         }
    }
    

    I cannot guarantee that this will work as I do not know if prismMainPage is expecting an Application instance as a Parent. But, since it would be easy to try, give it a shot and let me know if it works.

    Thursday, July 6, 2017 11:49 AM
  • User116727 posted

    @BuildCalc @Hiran_Peiris Prism doesn't have a bootstrapper anymore. In the OnInitialize, you can just set the MainPage manually and not use the NavigationService.

    Thursday, July 6, 2017 5:41 PM
  • User2122 posted

    @BrianLagunas

    Thanks for the expert advice!

    Thursday, July 6, 2017 6:31 PM
  • User306286 posted

    Hi,

    I run into this problem when building for IOS

    Error MT2002: Failed to resolve 'System.Reflection.Emit.DynamicILInfo' reference from mscorlib, Version=2.0.0.0 I am using package version 0.10.3.0

    I think it is related to Forms9Patch library because it builds perfectly without it. Thank you for any help.

    Friday, July 7, 2017 10:24 AM
  • User2122 posted

    @jhoemar

    Two things I might ask:

    1. Do you have the same issue with the Forms9Patch demo app?
    2. Can you PM me your Xamarin/VisualStudio system details?

    Also, you've probably already seen this post but I thought I might mention it anyway.

    Friday, July 7, 2017 12:07 PM
  • User128353 posted

    @BuildCalc,

    I've run into an issue where the Forms9Patch label resizing does not work correctly on the Samsung Galaxy S8 and other devices that have the new aspect ratios (18:9 and 18.5:9).

    Here for some details on the aspect ratios:

    https://stackoverflow.com/questions/43151092/setting-up-the-android-emulator-with-a-larger-screen-aspect-ratio

    I've tried setting ResizeableActivity=False and that works, but the user gets a “Tap here to fill entire screen” button in the empty space which then overrides my ResizeableActivity setting when tapped and is stored permanently.

    I haven't been able to get an emulator to emulate the aspect ratio correctly.

    I'll send you the screenshots of the non-resized text version from the S8 before they tap the "fill the entire screen" and after they tap it.

    Any help would be appreciated. Thanks!

    Monday, July 10, 2017 10:50 PM
  • User2122 posted

    @renzska - Just following up on the email I sent you on the 10th. Would you be able to send me the latest layout file for what you're seeing?

    Wednesday, July 12, 2017 12:05 PM
  • User107330 posted

    Hi @BuildCalc. First of all, your component is amazing. I`m going to use BubblePopup in my project, but I faced a bug. When I use MasterDetailPage and FormsAppCompatActivity, my detail page has top padding. Pages structure: public App() { InitializeComponent();

                MainPage = new RootPage(new MasterDetailPage { Master = new ContentPage { Title = "Test" }, Detail = new BubblePopupTestPage()})
                {
                    BackgroundColor = Color.Brown
                };
            }
    

    There is no problem with FormsApplicationActivity.

    Saturday, July 15, 2017 3:11 PM
  • User790 posted

    @BuildCalc I think the FAQ on the web site needs to be updated for the license key settings to reflect the Intialize() as Settings.LicenseKey is read-only

    Saturday, July 15, 2017 3:49 PM
  • User2122 posted

    @IlyaSemenchenko

    First, let me say THANK YOU for sending me a demo project that allowed me to quickly replicate this issue. I cannot say how much difference that makes between being able to understand an issue and just making some educated guesses (and wasting everyone's time).

    The root of this issue is a bug with Xamarin.Forms MasterDetailView that has yet to be fixed. To work around it, I would suggest making the following change to your MainActivity.cs file (in your Android project):

    ``` using Android.App; using Android.Content.PM; using Android.Views; using Android.OS; using Xamarin.Forms.Platform.Android;

    namespace Forms9PatchDemo.Droid { // COMMENT OUT THESE TWO LINES ... //[Activity(Label = "App1", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] //public class MainActivity : FormsAppCompatActivity

    // ... AND REPLACE WITH THESE TWO LINES.
    [Activity(Label = "App1", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : FormsApplicationActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
        // ADD THIS LINE
            Window.RequestFeature(WindowFeatures.ActionBar);
    
            base.OnCreate(bundle);
    
            global::Xamarin.Forms.Forms.Init(this, bundle);
            Forms9Patch.Droid.Settings.Initialize("NZPK-RMP4-PJVV-Z7LP-78JF-GNXB-CDJZ-SRYA-BLR2-WBZC-G64K-QJZW-65DB");
            LoadApplication(new App());
    
        // AND ADD THESE THREE LINES
            ActionBar.Hide();
            ActionBar.SetDisplayShowHomeEnabled(false);
            ActionBar.SetHomeButtonEnabled(false);
        }
    }
    

    } ```

    This is not a perfect solution but should get you up and going quickly. I would also suggest going to the Bugzilla link I gave above and adding your feedback as to why this bug needs attention.

    Sunday, July 16, 2017 2:49 PM
  • User2122 posted

    @CarlBarton --

    Thanks for letting me know about this. I've updated the web site accordingly.

    -- Ben

    Sunday, July 16, 2017 3:01 PM
  • User128353 posted

    @BuildCalc,

    I've sent you a sample.

    Thanks again for your help.

    • John
    Monday, July 17, 2017 5:36 PM
  • User204215 posted

    Hi Ben,

    We are using your library in our forms project (greta job btw, I'm loving your package ;) ) and we have one problem.

    We are creating ModalPopup with a pretty simple form layout (SS attached) with 3 entry fields, the problem is that when we provide a long text inside any of these entries application crashes - stack trace in stack_trace.txt file. Any help would be appreciated.

    Tuesday, August 8, 2017 12:18 PM
  • User2122 posted

    @MarcinDruzgala --

    First, let me apologize for taking so long to reply. I've been out on vacation for over a week and just now getting back to the internet.

    I've taken a look at the stack trace and have a lot of questions but no answers. Can you send me a small sample solution that demonstrates the issue you see? It is the only chance I'll have to replicate the issue - and therefore turn around a fix for you.

    Looking forward to finding the root cause of this issue.

    -- Ben

    Monday, August 14, 2017 11:29 AM
  • User107330 posted

    @BuildCalc Hi Ben. Thank you again for your great component. I have an issue on android with Bubble popup after updating Xamarin.Forms from 2.3.4.231 to 2.4.0.282. I attached test project and gif with the issue. Thank you!

    Friday, October 13, 2017 12:48 PM
  • User2122 posted

    @IlyaSemenchenko - I should be able to take a look later this weekend.

    Friday, October 13, 2017 1:15 PM
  • User2122 posted

    @IlyaSemenchenko -

    I've found the root cause. For the curious, it was caused by a change by Xamarin to how Xamarin.Forms.Platform.Android.MotionEventHelper.cs (line 24) deals with events that have been claimed by a motion event listener. Works great for them but it left external motion listeners out in the cold.

    I'm on the road for the rest of the week. It will take some time to run the fix through the merge - build - test process. Can you wait until mid-next week for a patch?

    Thursday, October 19, 2017 8:01 AM
  • User2122 posted

    Announcing UWP pre-alpha support in Forms9Patch version 0.9.3.5

    The following Forms9Patch elements are "pre-alpha" for UWP, meaning they mostly work but are not complete:

    • ImageSource
    • Image
    • ImageButton
    • ImageButtonState
    • MaterialButton
    • MaterialSegmentedControl
    • Segment
    • RootPage
    • ActivityIndicatorPopup
    • ModalPopup
    • PermissionPopup
    • Toast
    • AbsoluteLayout
    • BubbleLayout
    • ContentView
    • Frame
    • Grid
    • ManualLayout
    • RelativeLayout
    • StackLayout
    • Display
    • ApplicationInfoService

    Correspondingly, the following are not working:

    • custom fonts
    • Label
    • HtmlText property
    • Image.TintColor
    • ColorGradientBox
    • BubblePopup
    • TargetedToast
    • the Xamarin.Forms.WebView extensions
    • the ToPng() string extension
    • KeyboardService
    • KeyClicksService
    • StatusBarService

    Steps to integrate Forms9Patch into a Xamarin.Forms UWP app

    1. Follow the following steps to create the UWP project for your Xamarin.Forms app: https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/
    2. Add Forms9Patch nuget package (version >= 0.10.3.5)
    3. In the UWP project's App.Xaml.cs file, replace the Xamarin.Forms.Init(e); line (you added earlier in Step 1) with the following lines:

              var assembliesToInclude = Forms9Patch.UWP.Settings.AssembliesToInclude;
              Xamarin.Forms.Forms.Init(e, assembliesToInclude); 
              Forms9Patch.UWP.Settings.Initialize(this, _put_the_Forms9Patch_license_key_for_this_app_here_ );
      
    4. Set the UWP apps display name:

      1. Open the UWP project's app manifest (double click on the Package.appxmanifest file in the UWP project).
      2. In the [Application] section, set the "Display Name:" to the name associated with your Forms9Patch license key.
      3. In the [Packaging] section, set the "Package display name:" to the name associated with your Forms9Patch license key.
    5. Enable XAML Compilation: In every project that has XAML to display, add the following line to the project's Properties/AssemblyInfo.cs file. Note: Don't make the same rookie mistake I did and put the following line in the UWP project's (instead of the PCL project's) AssemblyInfo.cs file.

              [assembly: Xamarin.Forms.Xaml.XamlCompilation(Xamarin.Forms.Xaml.XamlCompilationOptions.Compile)]
      
    Thursday, October 26, 2017 4:59 PM
  • User277850 posted

    @BuildCalc Is it support .NET Standard?

    Tuesday, November 7, 2017 5:20 AM
  • User218602 posted

    I'm getting a System.ObjectDisposedException when trying to access Forms9Patch.Display.Scale. This happens when the app is opened after closing it with the 'back button'.

    This happens on a Android device.

    StackTrace: Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Util.DisplayMetrics'. Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<ba355e3003ed40e09d58ceb21a0e4742>:0 Java.Interop.JniPeerMembers.JniInstanceFields.GetSingleValue(string encodedMember, IJavaPeerable self)<ba355e3003ed40e09d58ceb21a0e4742>:0 Android.Util.DisplayMetrics.get_Density()<e8c278140cd04eb9aca58be4b40cb2f5>:0 FormsGestures.Droid.DisplayService.get_Scale()<25ff0297538f4290aa49c95f31da6f2c>:0 FormsGestures.Display.get_Scale()<4cc8da7996814a0cb2f6f675d64c3c91>:0 Forms9Patch.Display.get_Scale()<64fc257cc6d04551abf38a6b5c5abafe>:0

    When I try to access Android.Util.DisplayMetrics.Density myself, it does work.

    Other information:

    ! * Target API: 26 ! * Device API: 23 ! * Forms9Patch: 0.10.3.5 ! * Xamarin Forms: 2.4.0

    Wednesday, November 29, 2017 3:02 PM
  • User218602 posted

    After a downgrade to Forms9Patch 0.10.3.4 the Exception is gone. Will use that version for now.

    Thursday, November 30, 2017 10:45 AM
  • User364326 posted

    Hi!

    Which is the minimum version of Android that Forms9 is intented to be compatible with?

    Because it seems that is using the setClipBounds function, that if i'm not wrong was added in Android version 4.3 r2.1, so I get an exception of "no such method" for versions below that! :-(

    Thanks in advance

    Thursday, January 4, 2018 7:49 PM
  • User2122 posted

    @manueljben -

    You are correct. Forms9Patch uses Android.Views.View.ClipBounds as a way to assure proper rendering of shadows on SegmentedControl buttons. I remember considering other options but that was (by far) the least complicated approach. To reduce redundancy (never write the same code twice), it's used in all Forms9Patch Image, layout and button code. So yes, Android 4.3 would be the minimum version required for full functionality.

    Which leads to the heart of your question: Why didn't I set the minimum build target correctly? That is my mistake (clearly a bug). Alternatively, I could have shadows not work on versions of Android less than 4.2. Before I go off and fix this, I would like to consider which approach would be best. Do you have an opinion?

    • Ben
    Thursday, January 4, 2018 8:18 PM
  • User2122 posted

    @jvoostv1 -

    Check out Forms9Patch v1.0.1.2. It should have this issue fixed.

    Also, note that versions 1.0+ have significant changes to class and property names to more accurately reflect functionality and to be more consistent with Xamarin.Forms names. Although the online documentation has yet to be updated (in progress), the built-in documentation is up to date and so intellisense should be very helpful in guiding you through the changes.

    Thursday, January 4, 2018 8:23 PM
  • User2122 posted

    @Kyle_John -

    As of version 1.0, there are now two Forms9Patch nuget packages. Check out Forms9Patch.NetStandard for the .NetStandard version.

    FWIW, I wasted over a day trying to make one package work for both PCL and .NetStandard. I was successful for iOS and Android but I couldn't figure out how to do it for UWP.

    Thursday, January 4, 2018 8:26 PM
  • User2122 posted

    @manueljben -

    v 1.0.1.3 is now live on Nuget.org. It should be compatible with all versions of Android greater than or equal to Gingerbread (Android v2.3, API 9). Note that, this update also means that SegmentedController.HasShadow will not work on devices running Android versions older than JellyBean mr2 (4.2.x, API 17).

    Friday, January 5, 2018 2:32 AM
  • User364326 posted

    Oh, glad to hear that!

    You've been so quick to patch it that it is published before I even answered your previous message, sorry :)

    Thank you very much for your support!

    @BuildCalc said: @manueljben -

    v 1.0.1.3 is now live on Nuget.org. It should be compatible with all versions of Android greater than or equal to Gingerbread (Android v2.3, API 9). Note that, this update also means that SegmentedController.HasShadow will not work on devices running Android versions older than JellyBean mr2 (4.2.x, API 17).

    Friday, January 5, 2018 6:59 AM
  • User2122 posted

    Forms9Patch version 1.1 is now available

    What's so special about it? SVG is now fully supported as a Forms9Patch.Image.Source. This means you can: 1. apply Tile, AspectFit, AspectFill, and Fill Forms9Patch.Fit to SVG images 2. apply Rectangle, Square, Circle, Ellipse, and Obround clipping, colored background, and outline (via ElementShape property) 3. use SVG images as BackgroundImage for Forms9Patch buttons and layouts 4. use SVG images as IconImage for Forms9Patch buttons

    And, like other Forms9Patch images and fonts, you can store your SVGs as Embedded Resources and then load them as follows:

    ``` var svgImage = new Forms9Patch.Image { Source = "Yourembeddedresource.svg" };

    // or more conveniently
    var quickSvgImage = new Forms9Patch.Image("Your_embedded_resource.svg");
    

    ```

    And as XAML (if you use a ImageMultiResourceExtension in your Shared/PCL/NetStandard project): <Image Source="{local:ImageResource Your_embedded_resource.svg }"/>

    The online documentation has still not been updated but the built-in documentation has so you can get guidance via Intellisense. Likewise, the GitHub demo app is great resource for seeing all of the new features in action.

    Saturday, January 6, 2018 6:19 PM
  • User128353 posted

    Ben,

    Thanks again for the great work on this. I just updated to 1.1.0 and am running into an issue.

    The first is that my large text that was autosizing is currently not working with any v1+ version.

    I'm using the following styles:

    ```

    <Style x:Key="MainLabelMenuStyle" TargetType="forms9patch:Label" BasedOn="{StaticResource MainLabelStyle}">
        <Setter Property="Margin" Value="20,0,20,0" />
        <Setter Property="FontSize" Value="Large" />
        <Setter Property="FontAttributes" Value="Bold" />
        <Setter Property="HorizontalTextAlignment" Value="Start" />
    </Style>
    

    ```

    And using it like so:

    <forms9patch:Label Text="{local:Translate ChangeStatus}" Style="{StaticResource MainLabelMenuStyle}" />

    When running version 0.10.3.5, it shows as follows (what I'm expecting):

    When running version 1.1.0, it shows as follows:

    This started occurring with 1.0.0.

    Thanks,

    John

    Wednesday, February 14, 2018 8:32 PM
  • User2122 posted

    @renzska -

    Can you send me a quick demo app that replicates this? This is something that the testing didn't catch and I'm not seeing it in the demo app.

    Wednesday, February 14, 2018 8:43 PM
  • User128353 posted

    @BuildCalc, I've attached a test project that shows the issue. It is pointing to 0.10.3.5 right now. When I updated both package references to 1.0.0, the font size decreases dramatically as in my previous post.

    Thanks for looking into this.

    Wednesday, February 14, 2018 9:20 PM
  • User2122 posted

    @renzska -

    Thanks, I'll be able to look at it in the morning.

    Wednesday, February 14, 2018 9:21 PM
  • User2122 posted

    @renzska - I've verified the issue (thanks a million for the demo solution). It's also present on the dev branch so I'll start there.

    Friday, February 16, 2018 12:49 AM
  • User2122 posted

    @renzska - You found an edge case that I didn't test. I have the dev branch fixed and, after I fix an unrelated bug, I will run through the test suite and then build a new Nuget package.

    In the meantime, I should mention that your demo solution is using the AutoFit=AutoFit.Width property (formerly Fit=Fit.Width) without specifying the number of lines in the Lines property. The default number of lines is zero which should be interpreted by Forms9Patch.Label as a request to ignore the AutoFit property and "scale the font to fit the available space" (limited to a value between FontSize and MinFontSize). I'm not sure that is what you want in the example you provided.

    That being said, the simplest change would be for you to add a Lines=1 to each of your Labels. However, there could be scenarios where some of the lines of text would be longer than others and you would have noticeable differences in font size. If that is important to you, Forms9Patch gives you a couple of options you likely won't find elsewhere.

    The first option is to keep an eye on the FittedFontSize property. In the current versions, it can be done but that approach is obsolete for good reason. When the update to the Nuget package comes out, there will be a public event EventHandler<double> FittedFontSizeChanged; event that passes the latest and greatest FittedFontSize when it is fired. You can then keep track of the smallest FittedFontSize for all of your labels in question and (here's the really cool part) set the SynchronizedFontSize for all of them to that smallest size.

    If that is a bit complicated then, in some cases, the second option might be useful. That's because the SegmentedControl does all of the FittedFontSize and SynchronizedFontSize management automatically. For your use case, you could setup a SegmentedControl with a vertical orientation and no background color or outline. It's not exactly what you've got in the demo app but it could be quite close.

    Friday, February 16, 2018 2:28 AM
  • User128353 posted

    Thanks for looking into this. I'll update to the new version when it's available and then work at looking at your recommendations.

    Friday, February 16, 2018 3:53 PM
  • User2122 posted

    Sounds good. And, if you wish, you can apply the recommendations now and address the issue you're seeing before the next version is available.

    Friday, February 16, 2018 4:04 PM
  • User2122 posted

    Forms9Patch 1.1.1 is now available.

    There are a number of bug fixes and improvements so take a look at the release notes.

    Please note that the Forms9Patch nuget package now works for PCL, Shared, and .NetStandard applications. This means the Forms9Patch.NetStandard nuget package is now redundant. With that in mind, Forms9Patch.NetStandard will not be updated beyond 1.1.1. If you are using Forms9Patch.NetStandard, please switch to the Forms9Patch nuget package.

    Monday, February 19, 2018 7:26 PM
  • User346888 posted

    I think I found a bug - I don't have a sample project right now, unfortunately, but I'll try to create one if you need. Here are the steps I think are causing the problem, though:

    Using a SyncFusion Listview (Guess Xamarin has the same problem, though), the F9P Label control works fine for all the items that are loaded during the initial load. However, if you add items to the ItemsSource after the control has loaded (say during the onScroll event), then for the labels that were added after the initial load, if you click/tap on them, you get a null reference error and crash.

    The stacktrace didn't look too useful -

    at FormsGestures.Droid.NativeGestureListener.get_HandlesLongPresses () [0x00000] in <d6f2bad739c34f839278591ac7602c8c>:0 at FormsGestures.Droid.NativeGestureListener.LongPressTimerStart () [0x00008] in <d6f2bad739c34f839278591ac7602c8c>:0 at FormsGestures.Droid.NativeGestureListener.OnDown (Android.Views.MotionEvent e) [0x0001c] in <d6f2bad739c34f839278591ac7602c8c>:0 at Android.Views.GestureDetector+SimpleOnGestureListener.n_OnDown_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x0000f] in <848bbd7c681a4975918c72f17d2f5144>:0 at (wrapper dynamic-method) System.Object:3506515b-6998-4c73-affe-dd48d27dac6d (intptr,intptr,intptr)

    I don't need my labels to be tapable, so I just slapped a transparent boxview over them for now, which avoids the problem.

    Friday, February 23, 2018 2:50 PM
  • User346888 posted

    I think I found a couple bugs -

    One is reproducible from the sample project. In the LabelAutoFit page, change the text1 string to contain a "
    ". IE: static string text1 = "<b><em>Lgoryem</em></b> <br>ipsygum";

    Then run the project and use the settings AutoFit = Width, Lines = 2, Font > 32. The text grows too large and doesn't fit inside the label.

    For the second one, I don't have a sample project right now, unfortunately, but I'll try to create one if you need. Here are the steps I think are causing the problem, though:

    Using a SyncFusion Listview (Guess Xamarin has the same problem, though), the F9P Label control works fine for all the items that are loaded during the initial load. However, if you add items to the ItemsSource after the control has loaded (say during the onScroll event), then for the labels that were added after the initial load, if you click/tap on them, you get a null reference error and crash.

    The stacktrace didn't look too useful -

    at FormsGestures.Droid.NativeGestureListener.get_HandlesLongPresses () [0x00000] in <d6f2bad739c34f839278591ac7602c8c>:0 at FormsGestures.Droid.NativeGestureListener.LongPressTimerStart () [0x00008] in <d6f2bad739c34f839278591ac7602c8c>:0 at FormsGestures.Droid.NativeGestureListener.OnDown (Android.Views.MotionEvent e) [0x0001c] in <d6f2bad739c34f839278591ac7602c8c>:0 at Android.Views.GestureDetector+SimpleOnGestureListener.n_OnDown_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x0000f] in <848bbd7c681a4975918c72f17d2f5144>:0 at (wrapper dynamic-method) System.Object:3506515b-6998-4c73-affe-dd48d27dac6d (intptr,intptr,intptr)

    I don't need my labels to be tapable, so I just slapped a transparent boxview over them for now, which avoids the problem.

    Friday, February 23, 2018 2:50 PM
  • User2122 posted

    @gtgasby

    Could you slap together a quick demo project that shows these issues? I can't tell you how much faster I can respond when I don't have to try to guess all of the boundary conditions required to replicate the issue.

    Friday, February 23, 2018 4:34 PM
  • User2122 posted

    @gtgasby -

    I just ran the demo using your sample text as the value for Forms9Patch.Label.HtmlText property. Yes, the text does get larger (in height) than the constrained box IF the ImposeHeight switch is on. If I turn that switch off, the box grows (in height) to fit the text. The text never got any wider than the box. I tried this on iOS, Android and UWP.

    This may or may not be what you saw. It is the correct behavior for the AutoFit=AutoFit.Width and Lines=2 properties. Perhaps you are looking for Lines=0 or AutoFit.AutoFit.Height?

    Also, please sent me a demo project that demonstrates the null reference error. I'm guessing either the stack trace you shared with me is incomplete or something very strange occurred. I would really like to get to the bottom of it.

    Wednesday, February 28, 2018 9:39 PM
  • User790 posted

    I just updated to 1.1.1 and been running though any minor adjustments that are required. I have run into one issue that I am not sure how to fix. Here is the Xaml I am using:

    `

            <Grid
                Margin="20">
    
                <Image 
                    Source="{ext:ImageMultiResource GoOutdoors.Core.Resources.SunMoonSwitch.btn_switch_background}" />
    
                <f9p:Image 
                    x:Name="sunMoonSwitch"
                    Source="{ext:ImageMultiResource GoOutdoors.Core.Resources.SunMoonSwitch.btn_switch_sun}"
                    TintColor="{StaticResource PrimaryButtonBackgroundColor}"
                    Fill="AspectFit">
    
                    <f9p:Image.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding SunMoonSwitchCommand}" />
                    </f9p:Image.GestureRecognizers>
    
                </f9p:Image>
    
            </Grid>
    

    `

    We are swapping images when tapped to make a custom switch.

    On Android all this works fine as before but on iOS the TapGestureRecognizer Command is not getting executed.

    I will send you a sample. I was not able to upload it here. You will also notice that the default behavior with no Fill is not the same as a normal Image.

    Monday, March 5, 2018 7:01 PM
  • User2122 posted

    @CarlBarton -

    Yes, please send me some sample code. Without it, I'm not sure if I have a complete picture of what might be causing the issue.

    Also, I wanted to add that, looking at the image you attached, you might also be interested in the following alternative: use a Forms9Patch.Grid containing two Forms9Patch.StateButton elements. Both the grid and the state buttons would have their ElementShape = ElementShape.Obround. The Grid would also have BackgroundColor=Color.White and HasShadow=true. The state buttons would have DefaultState.BackgroundColor= Color.Transparent and their SelectedState.BackgroundColor= Color.Black. Then you could listen for theSelected event on each button and use that to unselect the other.

    Monday, March 5, 2018 8:26 PM
  • User790 posted

    @BuildCalc

    Thanks for the tip. I will give that a try. It was on my list of things to look at making better "in my spare time" but hadn't got to it yet. :smile:

    Thanks for the quick response -- as always.

    Carl

    Monday, March 5, 2018 9:22 PM
  • User2122 posted

    @CarlBarton -

    _Short Answer: _

    I'm not sure, but I think you've found a bug with Xamarin.Forms.Platform.iOS.EventTracker!

    _Long Answer: _

    In order to render a Forms9Patch.Image, I have a custom image renderer, Forms9Patch.iOS.ImageRenderer, that uses a custom iOS UIView (Forms9Patch.iOS.SkiaRoundedBoxAndImageView) as a child (it's a very cool class that is mostly code shared across iOS, Android, and UWP). When you do a touch, Xamarin.Forms.Platform.iOS.EventTracker receives a touch notification from Forms9Patch.iOS.SkiaRoundedBoxAndImageView as the touch argument, below.

    ``` bool ShouldReceiveTouch(UIGestureRecognizer recognizer, UITouch touch) { if (touch.View is IVisualElementRenderer) { return true; }

            // If the touch is coming from the UIView our renderer is wrapping (e.g., if it's  
            // wrapping a UIView which already has a gesture recognizer), then we should let it through
            // (This goes for children of that control as well)
            if (_renderer?.NativeView == null)
            {
                return false;
            }
    
            if (touch.View.IsDescendantOfView(_renderer.NativeView) && touch.View.GestureRecognizers?.Length > 0)
            {
                return true;
            }
    
            return false;
        }
    

    ``` Since Forms9Patch.iOS.SkiaRoundedBoxAndImageView isn't a renderer for a Xamarin.Forms.VisualElement (remember, it's a child of one), it fails the touch.View is IVisualElementRenderer test. Since the _render in this case is the renderer for Forms9Patch.iOS.ImageRenderer, it fails the second test (if (_renderer?.NativeView == null)) as well. Next, EventTracker tests to see if touch (a Forms9Patch.iOS.SkiaRoundedBoxAndImageView) is a child of a Xamarin.Forms.VisualElementRenderer - which it is (Forms9Patch.iOS.ImageRenderer). However, instead of testing to see if the _renderer?.NativeView (Forms9Patch.iOS.ImageRenderer) has any gesture recognizers, it tests touch! Perhaps that is intended, but for some reason, the touch event propagation ends there - it isn't being passed up the visual tree. However, if I changed the Xamarin.Forms.Platform.iOS.EventTracker to the following:

    ``` bool ShouldReceiveTouch(UIGestureRecognizer recognizer, UITouch touch) { if (touch.View is IVisualElementRenderer) { return true; }

            // If the touch is coming from the UIView our renderer is wrapping (e.g., if it's  
            // wrapping a UIView which already has a gesture recognizer), then we should let it through
            // (This goes for children of that control as well)
            if (_renderer?.NativeView == null)
            {
                return false;
            }
    
            if (touch.View.IsDescendantOfView(_renderer.NativeView) && touch.View.GestureRecognizers?.Length > 0)
            {
                return true;
            }
    
            if (touch.View.IsDescendantOfView(_renderer.NativeView) && _renderer?.NativeView.GestureRecognizers?.Length > 0)
            {
                return true;
            }
            return false;
        }
    

    ```

    The touch event works.

    Again, I'm not sure if this a Xamarin bug or not but I'm starting to think it's not a Forms9Patch bug (especially since the same code works on Android and UWP).

    I will file a bug report with Xamarin. In the meantime, I would highly recommend either using FormsGestures.Listener as an alternative to Xamarin.Forms.TapGestureRecognizer or switching over to using Forms9Patch.StateButton.

    You can useFormsGestures.Listener in your SandboxPage.Xaml and SandboxPage.Xaml.cs page as follows:

    ```

    <!--<WebView
        Source="http://georgiawildlife.com/hunting/resources"
        VerticalOptions="FillAndExpand"
        HorizontalOptions="FillAndExpand" />-->
    
    <StackLayout
        VerticalOptions="CenterAndExpand">
    
        <Label
            Text="Standard Image" />
    
        <Image
            Source="icon.png">
    
            <Image.GestureRecognizers>
    
                <TapGestureRecognizer
                    Command="{Binding TapCommand}" />
    
            </Image.GestureRecognizers>
    
        </Image>
    
        <Label
            Text="Forms9Patch Image" />
    
        <f9p:Image x:Name="myImage"
            Source="{local:ImageMultiResource Sandbox.Resources.icon}">
    
            <!--Image.GestureRecognizers>
    
                <TapGestureRecognizer
                    Command="{Binding TapCommand}" />
    
            </Image.GestureRecognizers-->
    
        </f9p:Image>
    
    </StackLayout>
    

    ```

    ``` using Xamarin.Forms;

    namespace Sandbox { public partial class SandboxPage : Xamarin.Forms.ContentPage { public Command TapCommand { get; set; }

        public SandboxPage()
        {
            InitializeComponent();
    
            /*
            TapCommand = new Command(async () =>
            {
                await DisplayAlert("Tapped", "You tapped it", "OK");
            });
            */
    
            var listener = FormsGestures.Listener.For(myImage);
    
            listener.Tapped += async (object sender, FormsGestures.TapEventArgs e) =>
            {
                await DisplayAlert("Tapped", "You tapped it", "OK");
            };
    
            BindingContext = this;
        }
    }
    

    }

    ```

    Monday, March 5, 2018 10:25 PM
  • User790 posted

    @BuildCalc So how the Image control is rendered has changed between 0.10.5 and 1.1.1? It was working in the 0.10.x versions...

    Tuesday, March 6, 2018 6:54 PM
  • User2122 posted

    Yes. My earlier implementation was VERY platform specific, making it quite a pain to maintain. Back when I was implementing UWP, I was done with everything but the button & layout shadows when I discovered just how hard that detail was going to be on UWP. That made me rethink my approach and I took a good hard look at SkiaSharp. In doing so, I (eventually) discovered it would mean > 95% of the renderer code could be shared across platforms. FWIW: this change has also enabled a number of other very cool enhancements, like: - shadows on images with transparent backgrounds - SVG images - background colors for images with transparent backgrounds - shaped borders that clip images to the border shape - much better image caching

    What does this have to do with the issue you found? As I mentioned, the older versions used my own platform views - that did not implement IVisualElementRenderer. However, the new approach uses SkiaSharp's native views - which does implement IVisualElementRenderer. This fact caused the Xamarin.Forms.Platform.iOS.EventTracker to catch the SkiaSharp native view instead of my renderer - and hence the issue you've seen. This is why I'm guessing this is a Xamarin.Forms bug since the touch event should have been passed up the visual tree but wasn't. One of the reasons I've posted such a lengthy explanation is because I'm hoping the internet will tell me that I'm wrong (and why) so I can fix it!

    Tuesday, March 6, 2018 7:09 PM
  • User790 posted

    Thanks. That makes sense.

    Tuesday, March 6, 2018 7:17 PM
  • User2122 posted

    Version 1.3.0 means Forms9Patch is now open source!

    No, I'm not orphaning Forms9Patch. In fact, just the opposite. I want more eyeballs on it to find any performance or reliability issues that I haven't noticed. I still have a lot of work catching the docs up to the current state of the code (there are a LOT of undocumented features!) so you'll find more than a few pleasant surprises if you take the time to explore the source.

    https://bitbucket.org/baskren/forms9patch2/src/master/

    Also, the demo app has been updated to show off a few of these new features. Again, you can find it here:

    https://github.com/baskren/Forms9PatchDemo

    This is my first open source project so I am looking forward to learning a lot from the process and your insights.

    Friday, May 11, 2018 12:13 PM
  • User128353 posted

    @BuildCalc I just ran our app on Android 9 and get the following crash on startup:

    08-15 20:31:11.709 31180 31180 I MonoDroid: UNHANDLED EXCEPTION:: com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: System.ArgumentException: Version string portion was too short or too long.: com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at System.Version+VersionResult.SetFailure (System.Version+ParseFailureKind failure, System.String argument) [0x0001c] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at System.Version+VersionResult.SetFailure (System.Version+ParseFailureKind failure) [0x00000] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at System.Version.TryParseVersion (System.String version, System.Version+VersionResult& result) [0x00029] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at System.Version.Parse (System.String input) [0x00023] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at System.Version..ctor (System.String version) [0x00014] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at Forms9Patch.Droid.OsInfoService.get_Version () [0x00005] in <78a0b497fc3a43108f03cc368361b3b6>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at Forms9Patch.OsInfoService.get_Version () [0x00005] in <8b8b8fecf8a24dc2b4f5c4c5172cacbb>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at Forms9Patch.Droid.SkiaRoundedBoxAndImageView.OnPaintSurface (System.Object sender, SkiaSharp.Views.Android.SKPaintSurfaceEventArgs e) [0x004f1] in <78a0b497fc3a43108f03cc368361b3b6>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at SkiaSharp.Views.Android.SKCanvasView.OnDraw (SkiaSharp.SKSurface surface, SkiaSharp.SKImageInfo info) [0x00013] in <96b23b5b974e4c6a9d6f8d221434e8d3>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at SkiaSharp.Views.Android.SKCanvasView.OnDraw (Android.Graphics.Canvas canvas) [0x000d0] in <96b23b5b974e4c6a9d6f8d221434e8d3>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x0000f] in <e4658a74547d4e3082ceb36ebd5e977c>:0 : com.p3tips.safeut 08-15 20:31:11.716 31180 31180 I MonoDroid: at (wrapper dynamic-method) System.Object.0f929bbf-cd0e-4087-b88f-7b0f876c227d(intptr,intptr,intptr): com.p3tips.safeut 08-15 20:31:11.720 31180 31180 W m.p3tips.safeu: JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable: com.p3tips.safeut 08-15 20:31:11.722 31180 31180 D AndroidRuntime: Shutting down VM: com.p3tips.safeut 08-15 20:31:11.726 1161 2901 I am_crash: [31180,0,com.p3tips.safeut,949534276,android.runtime.JavaProxyThrowable,System.ArgumentException: Version string portion was too short or too long.: system_server 08-15 20:31:11.726 1161 2901 I am_crash: at System.Version+VersionResult.SetFailure (System.Version+ParseFailureKind failure, System.String argument) [0x0001c] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at System.Version+VersionResult.SetFailure (System.Version+ParseFailureKind failure) [0x00000] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at System.Version.TryParseVersion (System.String version, System.Version+VersionResult& result) [0x00029] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at System.Version.Parse (System.String input) [0x00023] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at System.Version..ctor (System.String version) [0x00014] in <8f6fd9536e634dc1ab5ffbbf15c1e55f>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at Forms9Patch.Droid.OsInfoService.get_Version () [0x00005] in <78a0b497fc3a43108f03cc368361b3b6>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at Forms9Patch.OsInfoService.get_Version () [0x00005] in <8b8b8fecf8a24dc2b4f5c4c5172cacbb>:0 : system_server 08-15 20:31:11.726 1161 2901 I am_crash: at Forms9Patch.Droid.Sk^: system_server 08-15 20:31:11.727 1161 2901 W ActivityManager: Force finishing activity com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity: system_server 08-15 20:31:11.727 1161 2901 I am_finish_activity: [0,97930172,3045,com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity,force-crash]: system_server 08-15 20:31:11.727 1161 2901 I am_focused_stack: [0,0,75,finishActivity adjustFocus]: system_server 08-15 20:31:11.727 1161 2901 I wm_task_moved: [2,0,2147483647]: system_server 08-15 20:31:11.728 1161 2901 I am_pause_activity: [0,97930172,com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity,userLeaving=false]: system_server 08-15 20:31:11.729 1161 2901 I sysui_action: [316,-1]: system_server 08-15 20:31:11.729 1161 1185 I sysui_count: [window_time_0,69]: system_server 08-15 20:31:11.729 1161 2901 I sysui_multi_action: [757,316,758,4,759,-1]: system_server 08-15 20:31:11.729 1161 1185 I sysui_multi_action: [757,803,799,window_time_0,802,69]: system_server 08-15 20:31:11.729 31180 31180 I Process : Sending signal. PID: 31180 SIG: 9: com.p3tips.safeut 08-15 20:31:11.734 790 790 E lowmemorykiller: Error writing /proc/31180/oom_score_adj; errno=22: /system/bin/lmkd 08-15 20:31:11.747 1161 1445 W InputDispatcher: channel '7ce269 com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9: system_server 08-15 20:31:11.747 1161 1445 E InputDispatcher: channel '7ce269 com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!: system_server 08-15 20:31:11.748 719 719 I Zygote : Process 31180 exited due to signal (9) 08-15 20:31:11.748 1161 2180 I ActivityManager: Process com.p3tips.safeut (pid 31180) has died: vis +99TOP : system_server 08-15 20:31:11.748 1161 2180 I am_proc_died: [0,31180,com.p3tips.safeut,199,2]: system_server 08-15 20:31:11.748 1161 1188 W libprocessgroup: kill(-31180, 9) failed: No such process: system_server 08-15 20:31:11.748 1161 2152 I WindowManager: WIN DEATH: Window{7ce269 u0 com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity}: system_server 08-15 20:31:11.748 1161 2152 W InputDispatcher: Attempted to unregister already unregistered input channel '7ce269 com.p3tips.safeut/md52c34627382ae872580fa97c393738482.MainActivity (server)': system_server 08-15 20:31:11.748 1161 1188 I libprocessgroup: Successfully killed process cgroup uid 10204 pid 31180 in 0ms: system_server 08-15 20:31:11.748 1161 2180 I am_uid_stopped: 10204: system_server 08-15 20:31:11.758 1161 2180 I wm_task_removed: [3045,removeAppToken: last token]: system_server 08-15 20:31:11.758 1161 2180 I am_remove_task: [3045,75]: system_server 08-15 20:31:11.758 1161 2180 I wm_task_removed: [3045,removeTask]: system_server

    Here is the info I'm using:

    Version Number: 345 Version Name: 3.0.11

    Any ideas?

    Thursday, August 16, 2018 2:59 AM
  • User2122 posted

    @renzska -

    When you say Android 9, do you mean API level 28?

    • Ben
    Friday, August 17, 2018 12:18 PM
  • User2122 posted

    @renzska - OK, I think I see what's going on (assuming that, yes, you're using API 28). I've implemented a fix and will be releasing an update either today or Monday (depending on how the tests go).

    Friday, August 17, 2018 2:23 PM
  • User128353 posted

    Yes, API 28. Thanks for the quick turnaround on this!

    • John
    Friday, August 17, 2018 2:50 PM
  • User128353 posted

    @BuildCalc, any luck with the update? Schools are back in session and we're trying to get an update out as we're starting to get more crash reports. I could pull down the latest and build it on my end for testing and usage until you have a new version available. Which branch would be the best to do that from?

    Thanks again,

    John

    Tuesday, August 21, 2018 5:14 PM
  • User2122 posted

    Still working on fixing a UWP issue with the next release - but it should be good for your needs (all iOS and Android test pass). It's the "release-crash" branch.

    Tuesday, August 21, 2018 6:08 PM
  • User128353 posted

    @BuildCalc, I've been unsuccessful in getting Forms9Patch to build so far. Right now I'm getting an issue with the Forms.Flex not being present. I pulled the submodules and linked the packages folders (on Mac), but haven't had time to work past that. Any ETA on an updated release with the UWP issue and the Android 9 (API 28) issue resolved?

    Thanks,

    John

    Friday, August 31, 2018 4:45 PM
  • User377073 posted

    Thanks for the good ideas to bring it. I know a lot more.www.ufa007.com/ :) : J

    Saturday, September 1, 2018 7:22 AM
  • User2122 posted

    @renzska

    Thank you for your patience with me on this. I really wanted to get the updates right before submitting a new NuGet release. I've just uploaded 1.4.0 to NuGet.org and it should be available in a few minutes.

    Wednesday, September 5, 2018 2:53 PM
  • User2122 posted

    Forms9Patch 1.5 is available

    This is a maintenance update as there is no new functionality. However, under the covers, there are two important changes for reliability and performance:

    • Image and shape rendering has been refactored to eliminate platform specific code in favor of SkiaSharp.Views.Forms. This has eliminated a number of platform specific bugs!
    • Popups have also been refactored to eliminate the need for Forms9Patch.RootPage by using Rg.Plugins.Popups. This has resulted in fixing issues with using popups in pages that have been presented modally as well as popups presented over the Master page in MasterDetailPage.
    Friday, October 12, 2018 2:17 PM
  • User215149 posted

    @BuildCalc How can I set a native resource into forms9Patch Image control.? <forms9Patch:Image Source="ic_send.png"></forms9Patch:Image> Above one does not work.

    Monday, October 29, 2018 9:45 AM
  • User2122 posted

    @Favas - With Forms9Patch, I made a difference design decision with the default behavior of ImageSource. Rather than it referencing a file handle, by default it references a embedded resource in the main application assembly. Thus, in your example (if I remember correctly), it should be looking for an embedded resource named "ic_send.png" in the main application assembly (the assembly for your cross platform project).

    Why? Because my intent was to support a more cross platform approach in an effort to reduce the number of places needed to maintain resource files.

    Monday, October 29, 2018 12:12 PM
  • User215149 posted

    @BuildCalc I want to check the performance difference between Embedded(on Shared project) and Native resources(on platform specific projects). I tried "ic_send.png" as Embedded resource it works, but not from native resources.

    Tuesday, October 30, 2018 4:47 AM
  • User2122 posted

    @Favas -

    I would recommend testing it using code, rather than XAML. Forms9Patch.ImageSource.FromMultiResource or Forms9Patch.ImageSource.FromResource for your embedded resources and Xamarin.Forms.ImageSource.FromFile for your files. You also might want to compare their performance with both Xamarin.Forms.Image and Forms9Patch.Image as Forms9Patch.Image has built-in image caching for Embedded Resources and Files.

    Tuesday, October 30, 2018 5:06 PM
  • User383090 posted

    Hi @Favas . First of all thanks for the open source package. I am kinda new to Xamarin I have been using it for 2 months. So I have an application that requires Google Authentication which is fine and working properly. But my button is just a normal button and I am trying to use Google guidelines to create their button. I downloaded Google drawables from this page

    Since I made a new account I can't post links, so delete the ? inside htt?ps if you wish to use them :

    htt?ps://developers.google.com/identity/branding-guidelines

    htt?ps://developers.google.com/identity/images/signin-assets.zip.

    But no matter how I set up the button. I don't get the desired result.

    The closest I was to getting it to look properly was this :

        <f9p:Button  Text = "Sign in with xxhdpi"
                         TextColor="White"
                         FontSize="14"
                         FontFamily="sans-serif-medium"
                         WidthRequest="60"
                         >
                <f9p:Button.BackgroundImage>
                    <f9p:Image Source="{local:ImageMultiResource TestingApp.Resources.Images.btn_google_signin_dark_normal_xxhdpi}"/>
                </f9p:Button.BackgroundImage>
    
    
            </f9p:Button>
    

    I tried using a grid with image and button . Didn't work out. Tried using your statebutton, but google offers the icon for signin with the blue area for stretching. So the Icon is weird. If i use it for background only, I get the same problem as with normal button.

    First image is of the statebutton. The other three are from my experiments with button with different drawables. I would be eternaly gratefull if someone would enlighten me as to what to do.

    Same reason as for the links up, delete the ? inside htt?ps if you wish to see the images : h?ttps://imgur.com/a/gG87eWA

    Monday, March 4, 2019 10:20 AM
  • User2122 posted

    @Icolino

    I've actually done this before. Here is a general outline of what I did:

    1. Put your multi-platform icon files into your .NetStandard project as Embedded Resources. This means that I found all of the various resolutions provided by Google (_xxhdpi, _xhdpi, _hdpi, _mdpi, etc) and then renamed them to the followiing:

      • icon@¾x.png
      • icon.png
      • icon@1½x.png
      • icon@2x.png
      • icon@3x.png
      • icon@4x.png

      And then put them in to the "Resources/Google" folder in my project ("FormsFirebase.Ui"). So, for example, the EmbeddedResourceId for the first file, in the above list, is "FormsFirebase.Ui.Resources.Google.icon@¾x.png".

      As you will see in a moment, renaming these files, as shown above, will allow Forms9Patch.Button to pick the right image for the right screen resolution (so it will look great) - freeing you from having to manage this.

    2. In your Forms9Patch.Button, refer to the above icon image in a resolution independent fashion. This can be done a couple of ways. One of the more verbose ways is:

    ```csharp myButton.IconImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("FormsFirebase.Ui.Resources.Google.icon", GetType().Assembly), Padding = new Thickness(1, 1, 5, 1), TintIcon = false, };

    ```

    Notice that I am able to set the padding of the IconImage. This is in addition to being able to set the Forms9Patch.Button.Padding and the Forms9Patch.Button.Spacing (the distance between the IconImage and the Text or HtmlText, depending on if HasTightSpacing has been set to true).

    Now for a bit of proselytization (please forgive me if this does not apply to you): I see that you used XAML for your sample code. Notice I didn't in my response. If you are new to .Net and/or Xamarin.Forms, I would highly recommend not using XAML. Don't get me wrong, XAML is great - it's just not for beginners. Why? There's just too many things going on under the covers that, as a beginner, will trip you up and slow you down. Rather, I would recommend you write all of your UI in C# so you can learn to manage your properties and learn how binding really works. Once you have mastered making very efficient layouts with the best "context appropriate" use of binding, then you're ready for XAML. For me, the real test was being able to make very a complex cell layout in a large list in a ListView smoothly scroll on a low-end Android phone. After that experience, I was able to take advantage of all the benefits of developing in XAML (and there are many) without worrying about being shackled by my novice mistakes.

    Wednesday, March 6, 2019 1:02 PM
  • User383090 posted

    @BuildCalc

    Awesome explanation I loved it and now my xaml buttons are working as they should. So I am absolutely grateful for that.

    But I would love to be converted to your religion so I am trying to make it work with c#. To no avail. First Padding and Tint property are not there.

    And more importantly Icon is not being shown. But the size and height is appropriate. I tried with different Icons so it does somehow figure out the size correctly but leaves it empty. Resources are embeded and at appropriate place, they work through xaml.

    It's probably something simple. My project is Xamarin.Forms perhaps it's due to that somehow.

    namespace TestingApp
    {
        class Test : ContentPage
        {
            public Test()
            {
                var button = new Forms9Patch.Button { Text = "Google Sign In" };
    
                button.IconImage = new Forms9Patch.Image
                {
                    Source = Forms9Patch.ImageSource.FromMultiResource("TestingApp.Resources.Images.GoogleIcon.btn_google_dark_normal", GetType().Assembly),
                    TintColor = Color.Beige
                };
    
                Content = new StackLayout
                {
                    Children =
                    {
                    button
                    }
                };
            }
        }
    }
    

    The end result of above code (question mark again) :

    htt?ps://imgur.com/yXbFaF0

    Thank you once more.

    Thursday, March 7, 2019 1:33 PM
  • User2122 posted

    If your XAML is working then getting your C# to work should be a slam dunk. I have a couple requests:

    1. Show me a listing of the contents of your "TestingApp/Resources/Images/" directory.
    2. Replace the "TintColor=Color.Beige" line with "TintIcon=false"
    Thursday, March 7, 2019 1:53 PM
  • User383090 posted

    Image doesn't contain a definition of TintIcon, same as with padding. That seems to be the problem why Icon doesn't show up.

    One more thing I am using a c# ImageMultiResourceExtension for the xaml to find source image. So perhaps because of that xaml functions properly.

    There shouldn't be any problem from the directory, since that is what I am using for resource in Xaml. Contents, all resources are embeded :

    h?ttps://imgur.com/a/eJa75pt

    Thanks for taking the time to respond.

    Friday, March 8, 2019 11:24 AM
  • User2122 posted

    My fault. Remove TintColor from the image completely. Then, set button.TintIcon=false;

    Friday, March 8, 2019 11:49 AM
  • User2122 posted

    Also, no need for the 9 in the file names ... unless they are really 9-patch images.

    Friday, March 8, 2019 11:50 AM
  • User383090 posted

    Yeap, it was necessary to set button.TintIcon to false. The images are 9-patch. Thanks again. C# works as well now. One more thing I have opened a stackoverflow question at the same time for the same question. So if you don't mind I will user your answer there to close it. Unless you want to do it yourself.

    https://stackoverflow.com/questions/54981486/i-am-using-xamarin-forms-for-a-cross-platform-project-and-i-need-to-use-google-d

    Here it is.

    Monday, March 11, 2019 10:41 AM
  • User384889 posted

    @BuildCalc

    Hi, I use form9patch, it is grate. but I have a problem with BubblePopup , the pointer just point to left and right, and never point to top or bottom when I set pointer direction to vertical, it just the popup on then center of screen. is it a normal behavior or its a bug.

    Wednesday, April 24, 2019 6:31 AM
  • User2122 posted

    @mabdollahiasl

    There's a good chance this is normal behavior. In addition to the location of the VisualElement used for the BubblePopup.Target, rendering of the pointer depends on the values of the following BubblePopup properties: - Margin - Padding - HasShadow - PointerLength - PreferredPointerDirection - PointerDirection - WidthRequest - HeightRequest - HorizontalOptions - VerticalOptions

    ... as well as the measured size of the VisualElement used for the BubblePopup.Content property which can depend on a number of factors, including the size of its children and the values of its properties, such as: - Margin - WidthRequest - HeightRequest

    If, after taking into account all of the above, there are multiple directions, specified by PreferredPointerDirection, that have room for the BubblePopup and its pointer, BubblePopup will display the pointer in the direction with the most room.

    However, if, after taking into account all of the above, there is not enough room for the pointer in any of the directions specified by PreferredPointerDirection, BubblePopup will try to render a pointer in one of the directions specified by PointerDirection. If it cannot do that as well, BubblePopup will gracefully fail by presenting the content in a ModalPopup.

    In addition to giving the above properties a try, I would suggest taking a look at the Forms9PatchDemo BubblePopupTestPage to see some of this in action. If modifying those properties and the example doesn't help and you're still suspecting a bug, please go to the Forms9Patch repo and file a bug report. Don't forget to include an demo app the shows the issue you're seeing.

    Wednesday, April 24, 2019 12:12 PM
  • User384889 posted

    @BuildCalc said: @mabdollahiasl

    I Solved the problem, The problem was related to the content of the Popup. I used a grid with auto size in column and row, I set the exact size instead of auto and my problem solved, thanks.

    Wednesday, April 24, 2019 1:11 PM