An open API service indexing awesome lists of open source software.

https://github.com/nullsoftware/utoolkit

UToolKit contains different MVVM common use services for WPF.
https://github.com/nullsoftware/utoolkit

Last synced: 6 months ago
JSON representation

UToolKit contains different MVVM common use services for WPF.

Awesome Lists containing this project

README

          

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)

[![](https://img.shields.io/nuget/vpre/UToolKit)](https://www.nuget.org/packages/UToolKit/)
[![](https://img.shields.io/nuget/dt/UToolKit)](https://www.nuget.org/packages/UToolKit/)

# UToolKit
Library that contains useful tools for WPF application.
It is recommended to use this library with [Fody.PropertyChanged](https://github.com/Fody/PropertyChanged).

Main features:
- **ObservableObject** (`INotifyPropertyChanged` implementation)
- **IRefreshableCommand** (inherits `ICommand`, allows to call `ICommand.CanExecuteChanged` manually)
- **RelayCommand** (`IRefreshableCommand` implementation)
- **RelayAsyncCommand** (`IRefreshableCommand` async implementation)
- **RelaySingleTaskAsyncCommand** (`IRefreshableCommand` async implementation, designed for single task execution)

Converters:
- **InverseBooleanConverter**
- **BooleanToVisibilityConverter**
- **BooleanToHiddenVisibilityConverter**
- **InverseBooleanToHiddenVisibilityConverter**
- **InverseBooleanToVisibilityConverter**

Extensions:
- **ControlExtensions**
* `FocusMode` - focus mode for `Control`. There is two modes: `Default` and `FocusOnLoad`.
- **HyperlinkExtensions**
* `IsExternal` - if `true` Hyperlink will execute `Process.Start` using `Hyperlink.NavigateUri` after click.
- **WindowExtensions**
* `CloseCommand` - command which executes on windows closing. If `ICommand.CanExecute()` returns false - window closing will be cancalled.
* `CloseCommandParameter` - parameter for `CloseCommand`.
* `PlacementStorageStrategy` - window placement storage strategy.
There are 2 different implemented strategies, `RegistryStorage` and `SettingsStorage`.
It is possible to implement custom strategy using `IWindowPlacementStorage`.
- **RoutedCommand bindings** - allows to bind `ICommand` to `RoutedCommand`.

Services:
- **IWindowService** - (implementation: **WindowService**)
* `IsActive` - indicates whether the window is active.
* `IsVisible` - indicates whether the window is visible.
* `Activate()` - attempts to brind the window to the foreground and activates it.
* `Close()` - closes window.
* `Close(bool dialogResult)` - closes window with specified dialog result.
* `Hide()` - hides window.
* `Show()` - shows window.
- **ITextBoxService** - (implementation: **TextBoxService**)
* event `TextChanged` - informs that the text has changed.
* event `SelectionChanged` - informs that the selection has changed.
* `Text` - allows to get or set text to `TextBox` (will not break bindings).
* `CaretIndex` - gets current caret index.
* `SelectionLength` - gets selected text length.
* `SelectedText` - gets or sets selected text in text box (will not break bindings).
* `Select(int start, int length)` - selects a range of text in text box.
* `SelectAll()` - selects all text in text box.
- **IPasswordSupplier** - (implementation: **PasswordSupplier**)
* event `PasswordChanged` - occurs when the password of the `PasswordBox` changes.
* `Password` - allows to get or set password from/to `PasswordBox`.
* `SecurePassword` - gets secure password from `PasswordBox`.
* `Clear()` - clears all password.

## Getting started.
Use one of the follwing methods to install and use this library:

- **Package Manager:**

```batch
PM> Install-Package UToolKit
```

- **.NET CLI:**

```batch
> dotnet add package UToolKit
```
----
First you need to include namespace to your code or markup.

For **XAML** it can look like:
```XAML

```

And for **C#**:
```C#
using NullSoftware;
using NullSoftware.Services;
using NullSoftware.ToolKit;
using NullSoftware.ToolKit.Converters;
using NullSoftware.ToolKit.Extensions;
```
## Examples
To use converters just add `MergedDictionary` with source `pack://application:,,,/UToolKit;component/ToolKit/Converters.xaml` in your `App.xaml`:
```xaml








```
----

How to set `PlacementStorageStrategy`:

```XAML


```
or
```XAML

```
----
How to use `RoutedCommandHandlers`:
```XAML




















```