Reputation: 7063
How to include component in Xamarin.Forms?
Please suggest some component which supports dialog box, select pictures from library which is supported in Xamarin.Forms.
Because as per my knowledge, components can be added only to device specific project but not in common Forms project in Xamarin.Forms.
Thanks.
Upvotes: 0
Views: 1325
Reputation: 1161
Option 1 (ok) - Components :
as Jason stated, create an interface in the common library.
then create wrapper implementations within each device-specific project.
like each variation to the same interface using DependencyService
your common code will talk to the right instance of that interface, after it has been automatically injected.
Option 2 (worst) - Components :
if you can, use a Shared Library for your common Forms code.
then use compiler directives (#if #endif ...) in your class to separate device-specific implementation and probably different namespaces as well.
Option 3 (best) - Non-Components :
instead of using Xamarin Components, use NuGet in your PCL/SharedLib, and get the awesome Acr.XamForms, it has a User Dialogs and a Camera/Gallery lib
Upvotes: 1
Reputation: 89102
Include the component in your device-specific project, then use the Xamarin Forms' DependencyService to inject that device specific behavior into your common Forms project.
Upvotes: 0