DSoft.System.Mvvm.UI.Forms
3.4.2411.191
dotnet add package DSoft.System.Mvvm.UI.Forms --version 3.4.2411.191
NuGet\Install-Package DSoft.System.Mvvm.UI.Forms -Version 3.4.2411.191
<PackageReference Include="DSoft.System.Mvvm.UI.Forms" Version="3.4.2411.191" />
paket add DSoft.System.Mvvm.UI.Forms --version 3.4.2411.191
#r "nuget: DSoft.System.Mvvm.UI.Forms, 3.4.2411.191"
// Install DSoft.System.Mvvm.UI.Forms as a Cake Addin #addin nuget:?package=DSoft.System.Mvvm.UI.Forms&version=3.4.2411.191 // Install DSoft.System.Mvvm.UI.Forms as a Cake Tool #tool nuget:?package=DSoft.System.Mvvm.UI.Forms&version=3.4.2411.191
System.Mvvm.UI.Forms
Provides Xamarin.Forms platform implementations for DSoft.System.Mvvm.UI
Functionality
- UI
- Core UI functions for Showing Alerts and Confirmation Dialogs
- UI Thread execution
- Dependency injection support with
IPlatformCoreUIProvider
Using System.Mvvm.UI.Forms
The UI
static class provides four methods as defined in the IPlatformCoreUIProvider
interface.
- A central interface for calling some simple UI functions
ShowAlert(string title, string message)
- Show an alert with a title and message using the platform implementation
ShowConfirmation(string title, string message)
- Show a confirmation dialog and return the result using the platform implementation
InvokeOnUIThread(Action)
- Execute the action on the UI thread using the platform implementation
InvokeOnUIThreadAsync(Action)
- Execute the action on the UI thread asyncronously using the platform implementation
The standard UI
functions can be called directly after adding the DSoft.Mvvm.UI
package to your shared code
using System.Mvvm;
...
var result = await UI.ShowConfirmationDialogAsync("Confirm this", "This is a platform specific confirmation message");
if (result)
await UI.ShowAlertAsync("YAY!", "You confirmed that");
In the shared Xamarin.Forms project that contains the App
class(or other sub-class of Application
), add the DSoft.System.Mvvm.UI.Forms
package.
Note: do not add System.Mvvm.UI.Forms directly to the mobile application for iOS, Android or UWP
Call the MvvmManager.Init
method in the shared code, such as Application.OnStart
using System.Mvvm;
...
public partial class App : Application
{
protected override OnStart()
{
base.OnStart();
MvvmManager.Init();
}
}
Dependency Injection
Instead of using the static UI
class you can use dependency injection to access the platform implementation of IPlatformCoreUIProvider
using extensions for IServiceCollection
provided by the platform specific packages.
After adding DSoft.System.Mvvm.UI.Forms
to the application project you can register the core UI implementations of IPlatformCoreUIProvider
with the ServiceProvider during configuration of the services using the AddCoreUI
extension method.
using System.Mvvm;
...
public partial class App : Application
{
public App()
{
InitializeComponent();
ServiceHost.Host = new HostBuilder()
.ConfigureHostConfiguration(c =>
{
c.AddCommandLine(new string[] { $"ContentRoot={FileSystem.AppDataDirectory}" });
})
.ConfigureServices(ConfigureServices)
.Build();
}
void ConfigureServices(HostBuilderContext ctx, IServiceCollection services)
{
services.AddCoreUI();
}
}
Once the core UI is registered you can use IPlatformCoreUIProvider
with dependency injection in class constructors.
using System.Mvvm;
...
public class SharedClassToDoThingsIn
{
private readonly IPlatformCoreUIProvider _coreUIProvider;
public SharedClassToDoThingsIn(IPlatformCoreUIProvider coreUIProvider)
{
_coreUIProvider = coreUIProvider;
}
public async Task SayHello()
{
await _coreUIProvider.ShowAlertAsync("Congrats", "You called the ICoreUIProvider instance");
}
}
Use can also retrieve the implementation directly from the services provider or ServiceHost
if you are using DSoft.System.Mvvm.Hosting
using System.Mvvm;
...
var _coreUIProvider = ServiceHost.GetRequiredService<IPlatformCoreUIProvider>();
await _coreUIProvider.ShowAlertAsync("Congrats", "You called the ICoreUIProvider instance");
Using DI instead of the UI
does not require a call to MvvmManager.Init
though you do have to call the extension method to register the services. You can also use both.
IXamarinFormsPlatformUIProvider
IXamarinFormsPlatformUIProvider
is a platform specific interface that the platform implementation of `` implements. It provides access to some additonal Xamarin.Forms properties such as the current Application
.
Use can retrieve the implementation directly from the services provider or ServiceHost
if you are using DSoft.System.Mvvm.Hosting
using System.Mvvm;
...
var _formsUIProvider = ServiceHost.GetRequiredService<IXamarinFormsPlatformUIProvider>();
var currentApp = _formsUIProvider.CurrentApplication;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- DSoft.System.Mvvm (>= 3.4.2411.191)
- DSoft.System.Mvvm.Ui (>= 3.4.2411.191)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Xamarin.Essentials (>= 1.8.1)
- Xamarin.Forms (>= 5.0.0.2662)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.4.2411.191 | 81 | 11/19/2024 |
3.4.2406.251 | 116 | 6/25/2024 |
3.3.2405.241 | 105 | 5/24/2024 |
3.3.2405.21 | 123 | 5/5/2024 |
3.2.2301.91 | 333 | 1/9/2023 |
3.1.2208.151 | 469 | 8/15/2022 |
3.1.2205.231 | 526 | 5/23/2022 |
3.1.2205.52-beta1 | 181 | 5/5/2022 |
3.0.2202.121 | 528 | 2/12/2022 |
3.0.2111.271-prerelease | 226 | 11/27/2021 |
Updated to .NET 9.0 and latest packages