Xamarin.Forms DependencyService

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

When using DependencyService you typically need 3 parts:

  • Interface - This defines the functions you wish to abstract.
  • Platform implementation - A class within each platform specific project that implements the previously defined interface.
  • Registration - Each platform specific implementation class has to be registered with the DependencyService through a metadata attribute. This enables the DependencyService to find your implementation at run time.

When using DependencyService you are required to provide an implementation for each platform you target. When an implementation is not provided the application will fail at run time.



Got any Xamarin.Forms Question?