Frank.Wpf.Controls.SimpleInputs
1.0.0-preview
See the version list below for details.
dotnet add package Frank.Wpf.Controls.SimpleInputs --version 1.0.0-preview
NuGet\Install-Package Frank.Wpf.Controls.SimpleInputs -Version 1.0.0-preview
<PackageReference Include="Frank.Wpf.Controls.SimpleInputs" Version="1.0.0-preview" />
paket add Frank.Wpf.Controls.SimpleInputs --version 1.0.0-preview
#r "nuget: Frank.Wpf.Controls.SimpleInputs, 1.0.0-preview"
// Install Frank.Wpf.Controls.SimpleInputs as a Cake Addin #addin nuget:?package=Frank.Wpf.Controls.SimpleInputs&version=1.0.0-preview&prerelease // Install Frank.Wpf.Controls.SimpleInputs as a Cake Tool #tool nuget:?package=Frank.Wpf.Controls.SimpleInputs&version=1.0.0-preview&prerelease
Frank.Wpf.Hosting
Frank.Wpf.Hosting is a library that allows you to host WPF without XAML and using Dependency Injection.
Features
- Dependency Injection
- No XAML
- Multiple windows
Installation
dotnet add package Frank.Wpf.Hosting
Usage
using Frank.Wpf.Hosting;
public static class Program
{
[STAThread] // Required for WPF
public static void Main()
{
var builder = Host.CreateWpfHostBuilder(); // Create a WPF host builder
builder.Services.AddTransient<IMyService, MyService>(); // Register services
var host = builder.Build<MyWindow>(); // Create the host with the window inheriting from MainWindow
host.Run(); // Start the application and show the window
}
}
To get this point you need to create a window that inherits from MainWindow
:
using Frank.Wpf.Hosting;
public class MyWindow : MainWindow
{
public MyWindow(IMyService myService)
{
// Use the service
}
}
Advanced usage
If you want to have multiple windows, and not just dialogs, you can use the IWindowFactory
interface:
using Frank.Wpf.Hosting;
public class MyService : IMyService
{
private readonly IWindowFactory _windowFactory;
public MyService(IWindowFactory windowFactory)
{
_windowFactory = windowFactory;
}
public void DoSomething()
{
_windowFactory.CreateWindow<OtherWindow>(true); // Create a new window and show it (true)
}
}
You can also get the window by name using the IWindowFactory
interface:
using Frank.Wpf.Hosting;
public class MyService : IMyService
{
private readonly IWindowFactory _windowFactory;
public MyService(IWindowFactory windowFactory)
{
_windowFactory = windowFactory;
}
public void DoSomething()
{
_windowFactory.CreateWindow("DisplayWindow", true); // Create a new window and show it (true)
}
}
Note: The window name is the actual property name of the window, not the class name.
If you want to share data between windows, you can use the IApplicationCache
interface, and access it using the
Dispatcher
directly when needed:
using Frank.Wpf.Hosting;
public class DisplayWindow : Window
{
private readonly IApplicationCache _cache;
private readonly Label _label;
private readonly Timer _timer;
public DisplayWindow(IApplicationCache cache)
{
_cache = cache;
Title = "Hello, World!";
Name = "DisplayWindow";
Width = 800;
Height = 600;
_label = new Label
{
Content = "Hello, World!"
};
Content = _label;
_timer = new Timer(1000);
_timer.Elapsed += (_, _) => UpdateLabel();
_timer.Start();
}
private void UpdateLabel() => Dispatcher.Invoke(() => _label.Content = _cache.Get<string>("message")); // Access the cache using the Dispatcher because the timer runs on a different thread
}
public class InputWindow : Window
{
private readonly IApplicationCache _cache;
private readonly TextBox _textBox;
public InputWindow(IApplicationCache cache)
{
_cache = cache;
Title = "Hello, World!";
Width = 800;
Height = 600;
_textBox = new TextBox();
var button = new Button
{
Content = "Set message"
};
button.Click += (sender, args) => _cache.Set("message", _textBox.Text);
Content = new StackPanel
{
Children =
{
_textBox,
button
}
};
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. |
-
net8.0-windows7.0
- Frank.Wpf.Core (>= 1.0.0-preview)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Frank.Wpf.Controls.SimpleInputs:
Package | Downloads |
---|---|
Frank.Wpf.Dialogs
Package Description |
|
Frank.Wpf.Controls.JsonRenderer
A WPF control that renders JSON data in a tree view. |
|
Frank.Wpf.Controls.SearchableList
Package Description |
|
Frank.Wpf.Controls.HttpMessage
Package Description |
|
Frank.Wpf.Controls.RoslynScript
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
5.3.0 | 133 | 8/18/2024 |
5.2.0 | 131 | 8/17/2024 |
5.2.0-preview | 99 | 8/18/2024 |
5.1.0 | 128 | 8/17/2024 |
5.1.0-preview | 99 | 8/17/2024 |
5.0.0 | 127 | 8/16/2024 |
5.0.0-preview | 98 | 8/17/2024 |
4.0.0 | 117 | 8/15/2024 |
4.0.0-preview | 106 | 8/15/2024 |
3.1.0 | 126 | 8/12/2024 |
3.1.0-preview | 98 | 8/14/2024 |
3.0.0 | 130 | 8/12/2024 |
3.0.0-preview | 102 | 8/12/2024 |
2.3.0 | 110 | 8/12/2024 |
2.3.0-preview | 95 | 8/12/2024 |
2.2.0 | 103 | 8/7/2024 |
2.2.0-preview | 98 | 8/12/2024 |
2.1.0 | 68 | 8/5/2024 |
2.1.0-preview | 56 | 8/5/2024 |
2.0.0 | 70 | 8/4/2024 |
2.0.0-preview | 59 | 8/5/2024 |
1.5.0 | 109 | 7/20/2024 |
1.5.0-preview | 64 | 8/4/2024 |
1.0.0 | 94 | 7/19/2024 |
1.0.0-preview | 80 | 7/20/2024 |
0.3.0-preview | 75 | 7/19/2024 |