How to use Custom Renderer in Xamarin Shared Project - xamarin

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.

Related

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.

Store colors in common project to share between Android and iOS

I'm developing an app with Xamarin.Android and Xamarin.iOS. I would like to keep my color values (hex, rgb, or whatever) in a common project so that they can be accessed by both the Android and iOS projects. Is there a way to do this? I'm also using MvvmCross so is there a plugin for this? Or is this a bad idea?
I'm going to be using the colors in the Android layout files (.xml files) and back-end code for both platforms.
Is there a way to do this? [Share colors between platforms]
Yes, you can use MvxColor.* (With some limitations)
I'm also using MvvmCross so is there a plugin for this?
MvxColor is available via a plugin on NuGet.
Or is this a bad idea? [Share colors between platforms]
Use Case: I'm going to be using the colors in the Android layout files (.xml files) and back-end code for both platforms.
MvxColor will not work directly in XML. But can be used through bindings or assigning colors via the code behind. Therefore, if you want to use any Android XML design time tools with colors then MvxColor will not work.

Does Xamarin support to develop apps for Windows surface and how well?

I want to develop an app for Windows surface tablet and iOS mobile and iPad.
As I am a new user to Xamarin, when I created my first project,it shows 3 projects:-
hello.driod, hello.ios and hello.winPhone.
I have 3 questions based on this:-
How will I be able to write the same code and share for windows 8.1 and iOS?
and whenever I drag and drop the elements to the UI page, will the same elements be copied to both windows and iOS simultaneously or I got to add them seperately?
Currently I dont have a MAC to connect to my PC. Can I write the code and and there while testing it, connect it to a MAC or should it be connected during the whole process?
Please Help!
Using the same code depends on how your structure your app.
You can go the native route where you can share the bulk of your logic by containing it in a shared / PCL project (more on that here), but have platform specific code for your UI.
For example, if you have a cross platform app targeting iOS and Android you would still create the UI in a storyboard for iOS and AXML files for Android. Any code you want to "connect" to your UI would be specific to that platform as you would use the platform APIs. Any code that is not platform specific (i.e., not calling iOS or Android APIs) can go in your shared / PCL project.
Or you can choose Xamarin.Forms which adds a layer of abstraction by allowing you to write the UI in XAML once and have it work on all platforms. The advantage is increased code sharing as now your UI is also shared. The downside is to utilise platform specific features you'll need to implement DependencyService or custom renderers. Read more about Xamarin.Forms here.
As above, it depends. If you are going the native route, then no. If you are going with Xamarin.Forms, then you are using the same XAML code for the UI across platforms, but there is no drag and drop designer.
To build an iOS app you need to be connected to a Mac. You will also need to be connected to a Mac to use the iOS Designer.

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.

Xamarin.iOS + Xamarin.Forms - custom renderer in an iOS class library not found

I have four libraries all in all, a PCL and three platform-specific class libraries for Android, iOS and Win Phone. I have a base class for a custom Xamarin.Forms view in the PCL and renderers for it in the platform-specific libraries.
In the project where I use the libraries, the OnElementChanged() function of the iOS renderer is never called. I have tested on Android thus far, and there it works and the view gets rendered. Why might this be?
To complicate things, I have used the libraries in another project, where they work seamlessly on all three platforms.
I can provide more information if needed.
As there is not much info...
Make sure ExportRendererAttribute is set for the renderer
Make sure only one renderer available for the Control

Resources