Share via


IPlatformApplication.Current Property

Definition

Gets or sets the current platform application instance.

public:
 static property Microsoft::Maui::IPlatformApplication ^ Current { Microsoft::Maui::IPlatformApplication ^ get(); void set(Microsoft::Maui::IPlatformApplication ^ value); };
public static Microsoft.Maui.IPlatformApplication? Current { get; set; }
static member Current : Microsoft.Maui.IPlatformApplication with get, set
Public Shared Property Current As IPlatformApplication

Property Value

The current IPlatformApplication instance, or null if not set.

Examples

// Accessing a service from the platform application
var platformApp = IPlatformApplication.Current;
if (platformApp != null)
{
    var myService = platformApp.Services.GetService<IMyService>();
    // Use the service...
}

Remarks

This property provides access to the platform-specific application instance and its services. It must be manually set by each platform implementation during application startup.

Common usage scenarios:

  • Accessing platform services: IPlatformApplication.Current?.Services
  • Getting the application instance: IPlatformApplication.Current?.Application
  • Platform-specific operations requiring the native application context

Always check for null before using this property, especially during application startup or in unit tests where the platform application may not be initialized.

Applies to