With all the updates is easy to lose track of all the magic that you can do now in Xamarin Forms. If you developed using Forms a few months ago probably there were a lot of things that you needed a custom renderer to achieve them but now things are finally changing.
Here is a list of the best features that you probably didn’t know there is a property for it: π
Shadows
Every time I got a design with shadows was very frustrating because I knew that the only way to achieve it was by using a custom renderer. I got really happy when I saw that now we have ways to customize shadows without it.
You just need to import the ios platform-specific and use the properties ios:VisualElement.IsShadowEnabled=”true”, ios:VisualElement.ShadowColor=””, ios:VisualElement.ShadowOpacity=””, os:VisualElement.ShadowRadius=””.
ios:VisualElement.ShadowOpacity=””, os:VisualElement.ShadowRadius=””.
iOS:
Android:
On Android is not as powerful as on iOS, but to be fair Android is not very flexible when it comes to shadow customization.
So here you can use the platform specific android:Button.UseDefaultShadow=”True“
iPad Modal Page Presentation
This is a popular one, generally requested by customers supporting tablets in their apps. When navigating to a modal page in an iPad instead of showing a normal modal page, you can show it as a PopUp.
To achieve this you just have to set ios:Page.ModalPresentationStyle=”FormSheet” on the modal page you want to be displayed as PopUp.
Hide the status bar on iOS
Now is very easy to hide the status bar in a specific page by just using a property you can set if you want the status bar to be shown or not on that page.
Hide the home indicator on iOS
In the latest version of Xamarin Forms (4.0.0.425677) there’s a new feature that provides the ability to hide the Home Indicator on the page. To do it you just have to use the platform specific ios:Page.PrefersHomeIndicatorAutoHidden=”true”.
Entry power
The entries also have superpowers now, you can see new properties like CursorPosition, SelectionLength. Also on iOS, you have platform specifics to set the cursor color and adjust the text size when typing.
Button Pressed/Released Events
Now the Button has two new events to get feedback when the button has been pressed/released, those methods are useful when doing animations or in scenarios where you want to do an action when the button has been released.
This was just a summary of my favorite new properties but there’s even more, you can check more info in the official Xamarin documentation.
Final Notes
Congratulations to the Xamarin Forms team for the great job they are doing. Definitely, XF is going to the right path. Thanks π
9 Comments
Hi Charlin,
Thanks for this wonderful and clear explanation.
In your title image the first thing is adjustfontsizetofitwith, which I was very interested in. But I donβt see any explanation about this feature in your blog. Can you explain how this works please?
Thanks!
Have a nice day!
Basically, while you are writing a text in your entry it adjusts the text size.
Check this image: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/ios/entry-font-size-images/entry-font-size.png
Anything doubt me know.
Hey thanks it was awesome. I read your blogs.You are an awesome writer.
Hi Charlin,
Thank you for posting such useful information.
In your iPad Modal Page Presentation example, you access ios:Page.ModalPresentationStyle but ModalPresentationStyle is not available on my system. Is there another reference that must be used than Xamarin.Forms.PlatformConfiguration.iOSSpecific?
(I would send you a screenshot but I can’t from this form)
Hi Francis,
Did you added the iOS PlatformConfiguration reference:
xmlns:ios=”clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core”
…
Great article! Will definitely be using some of these.
Hi Charlin,
thanks for this great article.
I tried to hide the status bar on iOS, but it doesn’t work (only tried in the simulator).
I just copied the 3 XAML lines into my page’s XAML.
Do I have to make any project specific settings, too?
I’m using Xamarin.Forms v4.1.0.618606.
Great ! really helpful
Hi Charlin,
Firstoff: Thank you for your awesome posts. They helped improving my ui and useability a lot.
Is there a way to implement ModalPresentationStyle FormSheet in Android and UWP? I really like the idea to display a modal as a popup on tablets and desktop environments
Currently i’m using an absolute layout with a frame inside a slightly transparent layout on top of the current content to display a popup and achieve a “shadow” over the rest of the page.
Beeing able to use a modal for that on Android, iOS and UWP would make that so much easier. If you know an approch to use ModalPresentationStyle FormSheet on UWP and Android please let me know.
best regards