Reputation: 23
I want use differents components of UI for MAUI Blazor APP when its running in differents SOs. I meant, one custom component if its running on Android and other if it's running in Windows (due to well document webview bug when you try to use html selec in blazor maui for windows). There is some way to do this?, #if flag not semmeed to be work and i m using display size until now, but should be a better way. Thanks.
Upvotes: 0
Views: 1017
Reputation: 1751
You can install the following NuGet package which adds a Blazor component that can detect browser types, browser versions, device types and lots of other useful user agent information's.
nuget: https://www.nuget.org/packages/PSC.Blazor.Components.BrowserDetect/
GitHub: https://github.com/erossini/BlazorBrowserDetect
Upvotes: -1
Reputation: 610
Yes you can use Microsoft.Maui.Essentials.DeviceInfo
which contains Platform
as a property.
So you can do for example:
@if (DeviceInfo.Platform == DevicePlatform.iOS && DeviceInfo.Platform == DevicePlatform.Android)
{
<select></select>
}
else if (DeviceInfo.Platform == DevicePlatform.UWP)
{
<CustomSelect />
}
else
{
}
Upvotes: 1