Adita.Wpf.Hosting
1.0.0
Suggested Alternatives
Additional Details
Unification to PlexNet framework
dotnet add package Adita.Wpf.Hosting --version 1.0.0
NuGet\Install-Package Adita.Wpf.Hosting -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Adita.Wpf.Hosting" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Adita.Wpf.Hosting --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Adita.Wpf.Hosting, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Adita.Wpf.Hosting as a Cake Addin #addin nuget:?package=Adita.Wpf.Hosting&version=1.0.0 // Install Adita.Wpf.Hosting as a Cake Tool #tool nuget:?package=Adita.Wpf.Hosting&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Adita.Wpf.Hosting
A hosting library for .NET WPF application
How to use
Implement <code>Adita.Wpf.Hosting.IApplication</code> to your <code>App.xaml.cs</code>
public partial class App : Application, IApplication
{
//...
}
public void SetConfiguration(IConfiguration configuration)
{
Configuration = configuration;
}
public void SetServiceProvider(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}
Create a class to override entry point of application with <code>Main()</code> method
public static void Main()
{
IApplicationBuilder<App> builder = new ApplicationBuilder<App>();
//setup configuration
string appSettingsPath = Path.Combine(Environment.CurrentDirectory, "AppSettings.json");
builder.ConfigureAppConfiguration(configBuilder =>
{
configBuilder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(appSettingsPath, optional: false, reloadOnChange: true);
});
//add services
builder.ConfigureServices(services =>
{
services.AddSingleton<MainViewModel>();
services.Configure<TestOptions>(builder.Configuration.GetSection(nameof(TestOptions)));
});
App application = builder.Build();
//if App has components such as StartupUri, subscribes event handler to event(s) or others in here need to call InitializeComponent()
//InitializeComponent method of App class only will generated after build if any component exist.
//Note: if you delete the StartupUri on App.xaml you need to handle Startup event, otherwise InitializeComponent will never be generated
//and your app resource will not be initialized too, this is such as bugs of wpf!!!.
application.InitializeComponent();
application.Run();
}
Override StartupObject on project properties to your new entry point class
example:
<StartupObject>Adita.Wpf.Hosting.Sample.Startup</StartupObject>
Note: Sample project is on repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0-windows7.0
- Microsoft.Extensions.Configuration (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
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 | |
---|---|---|---|
1.0.0 | 494 | 10/8/2022 |
First release