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.
@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.
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.
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.
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.
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.
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
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
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
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!
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)
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")},
};
@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.
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();
@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.
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
@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.
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)?
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.
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.
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!
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
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(...).
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?".
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!
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?
@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.
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.
@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(...).
@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.
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.
Posts
@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.
@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.
@Ben Askren: I do not have GitHub ac can I upload zip file here...
@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
andPageRendererExtensionDispose
extensions public so nothing will break.@JSparrow -
Please take two minutes to get yourself a free Github account. Really worth the trouble.
New Feature Announcement
Forms9Patch now includes two new Features for its
Label
,MaterialButton
,Segment
, andImageButtonState
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>
UnderlineAdditionally, it provides the following style attributes, which can be used with any tag (even those not shown above):
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 tobold
to apply bold to the text. Onlybold
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 toitalic
to apply italics formatting to the text. Onlyitalic
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:
And the resulting screen shots:
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.
@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.
@BuildCalc, Thanks for your reply. I would like you to have a look into issue and let me know the solution.
@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.
@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.
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).
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.
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.
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!
FYI: Just updated to 0.9.13.2. This build includes:
IsElliptical
to layouts andMaterialButton
to make outline and fill elliptical rather than rectangular.Opacity
property ofImage
is now supported.HtmlText
property values with HTMLfont-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)StickyBehavior
property of buttons has been renamedToggleBehvior
and (forMaterialSegmentedControl
it has been changed toGroupToggleBehavior
)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
And this is my XAML
What am I doing wrong?
@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.
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
@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.
@BuildCalc Can you please provide me some samples for Modal and Bubble Popups with Xaml code (for the controls and binding).
Thanks.
@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.
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
@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.
@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)?
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 cyclesbool IgnoreChildren
property. Setting this property totrue
will cause the layout in question to ignoreInvalidateMeasure
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. SetIgnoreChildren
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.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 inHtmlText
properties. The demo app has an example of this in action. Just be sure to include anid
and/orhref
attribute because<a>
doesn't launch a browser window. Rather, it fires anActionTagTapped
event on yourForms9Patch.Label
instance and passesid
andhref
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
andActivityIndicatorPopup
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 colorpercent
betweenc
andc2
.static Color WithAlpha(this Color c, double alpha) usage: alphaColor = c.WithAlpha(c, alpha)
will return a modified version of colorc
where the opacity has been set toalpha
.static bool CanPrint(this WebView webview)
will return if you can print the contents of a Xamarin.Forms.WebView.CanPrint
returns true, you can usestatic void Print(this WebView webview, string jobname)
to print the contents of a Xamarin.Forms.WebView.static Color ToColor(this string s)
to take a HTML color string and turn it to a Xamarin.Forms.Color.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 theonComplete
action. See Forms9Patch.com for an example.Services
KeyboardService.Hide()
.KeyboardService.Shown
event.KeyboardService.Hidden
event.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.
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.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.
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!
@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(...)
.And, likewise, for your iOS project's AppDelegate.cs:
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?".
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!
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?
@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.
Cool, thanks.
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 calledUIScreen.MainScreen.NativeScale
which returns the correct device scale (3). You might want to update your implementation if that is the case.@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 callForms9Patch.iOS.Settings.LicenseKey = "a_valid_or_invalid_license_key_here";
in yourAppDelegate.cs
file (right afterglobal::Xamarin.Forms.Forms.Init(...)
.@BuildCalc you're correct! I just gave Forms9Patch a try and didn't put in the license key.
Thank you!
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
@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 axmlns: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 theImageMultiResource
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.
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:
On Android:
On iOS, it works if I set a Margin of 1 (shown in the style above).
Thanks!!
@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
@BuildCalc, I'll put one together and post it soon. Thanks!
@renzska: Looking forward to it.