Back to results for “Windows”
.NET MAUI › Desktop - WinUI & Mac Catalyst

How do you access native Windows (WinUI) APIs from MAUI?

Advanced

Answer

Guard code with #if WINDOWS and use the Windows App SDK/WinRT APIs, reaching the native control via Handler.PlatformView (a WinUI element). You can also add Windows-specific packages. Keep such code in Platforms/Windows or partial classes to isolate it.
#if WINDOWS
var native = (Microsoft.UI.Xaml.Controls.Button)button.Handler.PlatformView;
native.CornerRadius = new Microsoft.UI.Xaml.CornerRadius(12);
#endif
Real-world example A Windows build applies a WinUI-specific corner radius by reaching the native button through its handler.

Common follow-ups: Where does Windows-only code live? | What is the native type for a Button on Windows?