I'm making app with using Xamarin.forms.
I'm drawing 2d view with using SkiaSharp.
I'm able to use SetNeedDisplay on iOS pcl side to make animation.
But I want to call it from Forms pcl.
Is there any method like that?
SkiaSharp Views for Xamarin.Forms provides the InvalidateSurface() for this particular reason:
https://developer.xamarin.com/api/member/SkiaSharp.Views.Forms.SKCanvasView.InvalidateSurface()/
and
https://developer.xamarin.com/api/member/SkiaSharp.Views.Forms.SKGLView.InvalidateSurface()/
Related
I have a very important library written in swift with 3D rendering model on scenekit. So is there a way to mix native code screens and Xamarin screens without the need to go through the binding path? Meaning, I want to keep my app on xamarin as is, but I want to add some screens in pure native swift code.
So is there a way to mix native code screens and Xamarin screens
without the need to go through the binding path?
Short answer is no, you cannot.
When you have swift code and need to use it with xamarin apps you have only two ways.
Binding way as you mentioned
Rewrite you library from swift to c#.
In Xamarin Forms if you want to create animations quickly you can call any of the animation extension methods such as TranslateTo(x, y), etc according to:
https://developer.xamarin.com/guides/xamarin-forms/user-interface/animation/simple/
But they don't seem to cover everything. For example on the above link, I don't see:
A method to animate the background color?
A parameter to specify the easing factor?
What are the other animation limitations in Xamarin Forms API, compared to the full iOS and Android animation capabilities?
The "simple" ones are just the easy extension methods to do basic things. If you want the full control you need to use the animation class. There is even a background colour example a few pages below yours:
https://developer.xamarin.com/guides/xamarin-forms/user-interface/animation/custom/
Is it possible to mix iOS Storyboards and Xamarin Forms within one application? I have a bunch of views that are easier to be created in Forms, but some which are heavily customized so we would need to create some of them in native code.
I would like to use Storyboards to create the native parts, but can't seem to find a way to navigate from a Forms page to a Storyboard and vice versa.
I don't mind doing it from code, just need to know the direction to look into and if it's even possible.
You can create native views using the concept of Custom Renderers (see links below). The idea is that you create a Xamarin Forms Control that's shared between all platforms and which old common properties (like colors, general data etc), and do the native rendering on the iOS/Android/WP projects.
So, for your storyboard, you can create it usign Xamarin.iOS, and render using a Custom Renderer. The link posted by #GSerg in the comments have some information and examples, but you can take a closer look at the oficial documentation as well:
Introduction to Custom Renderers
Customizing Controls on Each Platform
Customizing Control Rendering in Xamarin.Forms (video)
Also, for more real world examples you can take a look at the Xamarin Forms XLabs project.
Thanks to Rafael Steil's answer. I looked at the links and a few more samples.
Notably:
Custom Renderer Map
Using Xamarin Forms alongside Storyboard
And I created a sample project to show the back-and-forth navigation between Xamarin Forms and pages created in Storyboards. You can find it over here:
Xamarin Forms Mixed with Native
I'm trying to draw new elements/images via the new skiasharp library for xamarin forms.
I got the samples working but they only change the full content page with the new canvas.
So my question would be how to implement a single view which can be placed in any place in another content page. Does anyone have experiences with skia?
How do I choose the canvas? Do I have to overwrite an existing Image or similar?
Thanks for you help.
Sure, and there is a view which you are looking for: SkiaView.
It inherited from Xamarin.Forms.View and contains some properties such as HeightRequest or Scale.
I suppose you are interested in these classes:
SkiaView
ISkiaViewController
iOS - SkiaViewRenderer
iOS - NativeSkiaView
Android - SkiaViewRenderer
Android - NativeSkiaView
EDIT:
Finally there is a NuGet package with Xamarin.Forms support: SkiaSharp.Views.Forms 1.54.1-beta1. Samples are available in SkiaSharp repository.
What is the best way to make an image slider with Xamarin Forms. I've tried using a CarouselPage but it is too slow and uses too much memory.
You can use ImageGallery on Xamarin Forms Labs project
Like this:
https://www.dropbox.com/s/h51bunhgannsv9v/ImageGallery.mov