How to embed Xamarin.Forms in native Xamarin.Mac? - xamarin

I'm trying to embed a XAML page created with Xamarin.Forms in my native Xamarin.Mac application.
How can I achieve that?

Check out this guide for embedding XAML in native UI. The approach is very similar to iOS, there is an analogous CreateViewController extension method available in Xamarin.Mac:
nativeViewController = new MyPage().CreateViewController();
_navigation.PushViewController(nativeViewController, true);

Related

Xamarin forms android webview video fullscreen

I have a webview that contains a video in my Xamarin forms application. Android does not allow for full screen but iOS does I know I could implement the WebChromeClient but I have only seen this done for Xamarin Android and not for forms. I can't seem to get it to work. Any ideas?
If you need to access the underlying native controls and their properties, methods and events, you do that with custom renderers.
I'm glad I found this because I don't think I could of done it on my own.
https://github.com/mhaggag/XFAndroidFullScreenWebView/tree/master/XFAndroidFullScreen/XFAndroidFullScreen

Using Xamarin.Forms with Native pages (Xamarin.iOS, UWP)

I already have a solution which consist of Xamarin.iOS and UWP. We have multiple views (Pages) in both platforms. We are using MvvmCross, so we have a common code (PCL) which consists of Viewmodels, business logic etc. Also, we have separate views (Pages) for both Xamarin.iOS and UWP.
Now I want to add Xamarin.Forms support for native pages of both projects so that we have same views for both Xamarin.iOS and UWP. We need the support of navigation (from Native to Xamarin.Forms & vice versa). I am navigating through MvvmCross navigation service.
For instance,
I have FirstFormView in Xamarin.Forms project.
I have SecondFormView in Native project (can be Xamarin.iOS or UWP).
I have ThirdFormView in Xamarin.Froms project.
I have navigated to FirstFormView (which is staring page of my application)
Now I want to go to SecondFormView (which is in native project).
And from SecondFormView I need to go to ThirdFormView which is again in Xamarin.Forms
Is it possible to do it MvvmCross? If yes, then what steps should we follow to achieve our desired goal.
Thanks in advance.
Regards,
This is possible through the Forms presenters. Take a look at the playground: https://github.com/MvvmCross/MvvmCross/tree/develop/TestProjects/Playground/Playground.Forms.Droid
Here the views are all Forms, but 1 or 2 are in Native. By using the same solution you should be able to do this.
You already have MvvmCross in your PCL project, just need to add Xamarin Form pages (XAML) for every page in platform specific project (iOS, UWP). And custom renderers for every platform.
For example:
//in xamarin forms pcl project
namespace XFormProject
{
public class MyXFormPage : ContentPage project
{
}
}
// in ios project
namespace XFormProjecy.iOS
{
[assembly:ExportRenderer(typeof(XFormProject.MyXFormPage), typeof(XFormProject.iOS.MyXFormPageIOS))]
public class MyXFormPageIOS : PageRenderer // in iOS
{
// your ios native page code goes here.
}
}
Read more about Custom Rederers
Hope this helps :)

How to enable Xamarin app as share target in Xamarin.Forms?

I have a Xamarin.Forms application that I would like to enable as a text and/or URL share target. I've done this in a Windows UWP app by handling OnShareTargetActivated, but I don't see an equivalent in Xamarin.Forms. I am willing to use compiler directives if needed; I would prefer that to doing iOS/Android/Windows specific things in the corresponding projects themselves. Right now all my code is in the Xamarin.Forms project and I'd like to keep it that way.
Unfortunately Android and Ios do not have a similar share event so there is no equivalent event in xamarin forms.

How to use Custom Renderer in Xamarin Shared Project

I am using Shared Project for my cross platform mobile application and want to use Custom renderer in my app for native support. Is there any way i can use Custom renderer in my app.
There is no difference in-between using custom renders in a PCL or Shared Project as seen here. You still have a project per platform. That doesn't change. The real advantage is that you can use ifdefs when compared to PCLs.
here is all the information you'll need in regards to implementing custom renders. And here is an example of a custom renderer for an Entry.
For Xamarin shared base project we have to set local in xmlns below format
xmlns:local="clr-namespace:Sampleforms"
For Xamarin PCL base project we have to set local in xmlns below format
xmlns:local="clr-namespace:Sampleforms;assembly=Sampleforms"
Reming everything will be same as what do for custom render.

Xamarin forms draw signature

Is there any plugin or default controls to draw signatures in Xamarin forms which will support in all platforms? Do I need to implement in all platforms using dependency service or custom renders?
You can check this component from Xamarin Components.

Resources