# BionicCode.Net [![GitHub](https://img.shields.io/github/license/BionicCode/BionicCode.Net)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![Release](https://img.shields.io/github/last-commit/BionicCode/BionicCode.Net)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) .NET libraries containing utilities and controls that target .NET Standard, .NET 5, .NET 5 WPF, .NET Core, .NET Framework, .NET Core WPF, .NET Framework WPF and UWP [![BC](https://img.shields.io/badge/.NET-7-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/.NET-6-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/.NET-5-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/.NET-Core-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/.NET-Standard-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/.NET-Framework-informational)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/-WPF-informational?logo=windows)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/-UWP-informational?logo=windows)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/-Windows_Forms-informational?logo=windows)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/-Linux-informational?logo=linux)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) [![BC](https://img.shields.io/badge/-macOS-informational?logo=apple)](https://github.com/BionicCode/BionicCode.Net#bioniccodenet--) ## NuGet Packages Download [![BionicCode.Utilities.Net.Wpf](https://img.shields.io/badge/.NET_5_WPF-BionicCode.Utilities.Net.Wpf-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Wpf/)[![BionicCode.Utilities.Net.Wpf.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Wpf.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Wpf/) [![BionicCode.Utilities.Net.Core.Wpf](https://img.shields.io/badge/.NET_Core_3.0_WPF-BionicCode.Utilities.Net.Core.Wpf-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Core.Wpf/)[![BionicCode.Utilities.Net.Core.Wpf.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Core.Wpf.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Core.Wpf/) [![BionicCode.Utilities.Net.Core](https://img.shields.io/badge/.NET_Core_3.0-BionicCode.Utilities.Net.Core-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Core/)[![BionicCode.Utilities.Net.Core.Wpf.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Core.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Core/) [![BionicCode.Utilities.Net.Standard](https://img.shields.io/badge/.NET_Standard_2.0-BionicCode.Utilities.Net.Standard-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Standard/)[![BionicCode.Utilities.Net.Standard.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Standard.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Standard/) [![BionicCode.Utilities.Net.Framework.Wpf](https://img.shields.io/badge/.NET_Framework_4.8_WPF-BionicCode.Utilities.Net.Framework.Wpf-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Framework.Wpf/)[![BionicCode.Utilities.Net.Framework.Wpf.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Framework.Wpf.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Framework.Wpf/) [![BionicCode.Utilities.Net.Framework](https://img.shields.io/badge/.NET_Framework_4.8-BionicCode.Utilities.Net.Framework-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Framework/)[![BionicCode.Utilities.Net.Framework.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Framework.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Framework/) [![BionicCode.Utilities.Net.Uwp](https://img.shields.io/badge/.NET_UWP-BionicCode.Utilities.Net.Uwp-orange)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Uwp/)[![BionicCode.Utilities.Net.Uwp.NuGet](https://img.shields.io/nuget/v/BionicCode.Utilities.Net.Uwp.svg?logo=nuget)](https://www.nuget.org/packages/BionicCode.Utilities.Net.Uwp/) ## [Class Reference](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/R_Project_Documentation.htm) [![BionicCode.Utilities.Net.Core.Wpf](https://img.shields.io/badge/Namespace-BionicCode.Utilities.Net.Core-orange)](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [![BionicCode.Utilities.Net.Framework.Wpf](https://img.shields.io/badge/Namespace-BionicCode.Utilities.Net.Framework-orange)](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) [![BionicCode.Utilities.Net.Standard](https://img.shields.io/badge/Namespace-BionicCode.Utilities.Net.Standard-orange)](https://www.sampoh.de/github/docs/bioniccode.net/bioniccode.utilities.net.standard/html/R_Project_Documentation.htm) [![BionicCode.Utilities.Net.UWP](https://img.shields.io/badge/Namespace-BionicCode.Utilities.Net.Uwp-orange)](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Uwp.htm) ## Table of Contents (selection) | class (example) |description |namespace | |---|---|---| | [`ViewModel`](https://github.com/BionicCode/BionicCode.Net#baseviewmodel) | Configurable implementation of `IViewModel`, `INotifyPropertyChanged`, `INotifyDataErrorInfo` with property validation support via delegates or Lambda expressions | [.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm)| | [`AsyncRelayCommand`](https://github.com/BionicCode/BionicCode.Net#asyncrelaycomandtcommandparam) | Implementatiom of `ICommand` that supports asynchrnous command execution. | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) [.Net.Uwp](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Uwp.htm)| | [Extension Methods for WPF](https://github.com/BionicCode/BionicCode.Net#Extension-Methods-WPF) | E.g., `DependencyObject.TryFindVisualChildElement`, `DependencyObject.TryFindVisualChildElementByName`, `DependencyObject.TryFindVisualParentElement`, `DependencyObject.TryFindVisualParentElementByName`, `DependencyObject.EnumerateVisualChildElements`, `object.ToDictionary` | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm)| | Extension Methods for .NET Standard | |[.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm) | | [ValueConverters](https://github.com/BionicCode/BionicCode.Net#ValueConverters) | Default implementations of `IValueConverter` and `IMultiValueConverter` e.g., `BooleanMultiValueConverter`, `FilePathTruncateConverter`, [`BoolToStringConverter`](https://github.com/BionicCode/BionicCode.Net#BoolToStringConverter), [`InvertValueConverter`](https://github.com/BionicCode/BionicCode.Net#InvertValueConverter) | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | | Collections WPF | `ObservablePropertyChangedCollection` | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | | [`Profiler`](https://github.com/BionicCode/BionicCode.Net#Profiler) | | [.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm) | | [`AppSettingsConnector`](https://github.com/BionicCode/BionicCode.Net#AppSettingsConnector) | A default API to the `AppSettings` that provides strongly typed reading and writing (e.g. `bool`, `int`, `double`, `string`) of key-value pair values. | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | |[`MruManager`](https://github.com/BionicCode/BionicCode.Net#mru-most-recently-used-file-manager) | Most Recently Used (MRU) file manager. An API that maintains an MRU table stored in the Application Settings file. | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | |[`EventAggregator`](https://github.com/BionicCode/BionicCode.Net#eventaggregator) |Implementation of the Event Aggregator pattern that supports dynamic aggregation of different typed event sources. | [.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm) | | [`AutoResetStream`](https://github.com/BionicCode/BionicCode.Net#autoresetstream) |A `Stream` decorator that automatically resets the stream's position after read/write access. | [.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm) | |[`Dialog`](https://github.com/BionicCode/BionicCode.Net#mvvm-dialog-attached-behavior) | Easy to use attached behavior and infrastructure to allow MVVM friendly dialog handling from a view model class in a fire-and-forget manner. To display dialogs implement `IDialogViewModel` classes and create a `DataTemplate` for each implementation. The `DataTemplate` is the rendered in a native `Window`. Addition attached properties allow for styling of the dialog `Window` or to assign an optional `DataTemplateSelector`. The attached behavior will handle showing and closing of the dialog. | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | | Attached Behaviors for WPF | [`Popup`](https://github.com/BionicCode/BionicCode.Net#popup) - e.g., allows to make the `Popup` sticky and moves it with the current placement target.
[`TextControl`](https://github.com/BionicCode/BionicCode.Net#textcontrol) - Allows to highlight text ranges in `TextBlock` and `RichTextBox` controls.
[`PasswordBox`](https://github.com/BionicCode/BionicCode.Net#passwordbox) - Enables to send the `PasswordBox.SecurePassword` value to the view model using a `ICommand`. | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | |EventArgs |[`ValueChangedEventArgs`](https://github.com/BionicCode/BionicCode.Net#valuechangedeventargst), [`ValueEventArgs`](https://github.com/BionicCode/BionicCode.Net#valueeventargst), `PropertyValueChangedArgs` | [.Net.Standard](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Standard.htm) | | Markup Extensions | [`InvertExtension`](https://github.com/BionicCode/BionicCode.Net#invertExtension), [`EnumExtension`](https://github.com/BionicCode/BionicCode.Net#enumExtension), `PrimitiveTypeExtension`, `EqualsExtension` | [.Net.Core.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) [.Net.Framework.Wpf](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Framework.htm) | --- ### `ViewModel` * Abstract base view model class that implements and encapsulates `INotifyPropertyChanged` and `INotifyDataErrorInfo`. * Allows to control whether invalid data is set on a property or neglected until validation passes by setting the default parameter `isRejectInvalidValueEnabled` of `TrySetValue()` to `true` (neglects invalid values by default). * Also allows to control whether to throw an exception on validation error or not (silent) by setting the default parameter `isThrowExceptionOnValidationErrorEnabled` of `TrySetValue()` to `true` (is silent by default). * Additionally exposes a `PropertyValueChanged` event which is raised in tandem with `INotifyPropertyChanged.PropertyChanged` but additionally carries old value and new value as event args. ## [Class Reference](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/R_Project_Documentation.htm) [![BionicCode.Utilities.Net.Core.Wpf](https://img.shields.io/badge/Namespace-BionicCode.Utilities.Net.Core-orange)](https://rawcdn.githack.com/BionicCode/BionicCode.Net/0dcf23826e90a9b54757fa705d77f263056f5fc6/Documentation/html/G_BionicCode_Utilities_Net_Core.htm) ```c# private string name; public string Name { get => this.name; set { if (TrySetValue( value, (stringValue) => { var messages = new List() {"Name must start with an underscore"}; return (stringValue.StartsWith("_"), messages); }, ref this.name)) { DoSomething(this.name); } } } ``` #### Example without validation ```c# private string name; public string Name { get => this.name; set { if (TrySetValue(value, ref this.name)) { DoSomething(this.name); } } } ``` ---- ### `AsyncRelayComand` Reusable generic command class that encapsulates `ICommand` and allows asynchronous execution. When used with a `Binding`, the command will always execute asynchronously as long as an awaitable execute handler is assigned to the command. #### Example Declare async `ICommand`: ```c# // ICommand. The command delegate 'Task ProcessStringAsync(string)' returns a 'Task' object and is awaitable. public IAsyncRelayCommand SomeAsyncCommand => new AsyncRelayCommand(ProcessStringAsync); ``` Execute XAML: ```XAML