BionicUtilities.Net
1.1.5
BionicCode.Utilities.Net.Framework.Wpf
Additional DetailsBreaking change: the library has been moved to a new package and namespace: "BionicCode.Utilities.Net.Framework.Wpf" (and the dependency to "BionicCode.Utilities.Net.Standard"). Please install the "BionicCode.Utilities.Net.Framework.Wpf" package from now on. Remarks: only the namespaces have changed. Class names remain the same (except the class 'BaseViewModel` has been renamed to 'ViewModel' and 'IBaseViewModel' to 'IViewModel'. The 'BaseViewModel' class and the 'IBaseViewModel' interface are still available for backward compatibility, but have been marked as deprecated). For the .NET Core version please install the new "BionicCode.Utilities.Net.Core.Wpf" package.
See the version list below for details.
dotnet add package BionicUtilities.Net --version 1.1.5
NuGet\Install-Package BionicUtilities.Net -Version 1.1.5
<PackageReference Include="BionicUtilities.Net" Version="1.1.5" />
paket add BionicUtilities.Net --version 1.1.5
#r "nuget: BionicUtilities.Net, 1.1.5"
// Install BionicUtilities.Net as a Cake Addin #addin nuget:?package=BionicUtilities.Net&version=1.1.5 // Install BionicUtilities.Net as a Cake Tool #tool nuget:?package=BionicUtilities.Net&version=1.1.5
BionicUtilities.Net
Reusable utility and class library for WPF.
NuGet package
Class Reference
Contains
Extension Methods for WPF e.g.
TryFindVisualParentElement<TParent> : bool
TryFindVisualParentElementByName : bool
TryFindVisualChildElement<TChild> : bool
TryFindVisualChildElementByName : bool
FindVisualChildElements<TChildren> : IEnumerable<TChildren>
ICollection.AddRange<T>
EventArgs
ValueConverters
BoolToStringConverter
BooleanMultiValueConverter
FilePathTruncateConverter
InvertValueConverter
Collections
ObservablePropertyChangedCollection<T>
MarkupExtensions
- PrimitiveTypeExtension
BaseViewModel
implements INotifyPropertyChanged
and INotifyDataErrorInfo
Example with validation
private string name;
public string Name
{
get => this.name;
set
{
if (TrySetValue(
value,
(stringValue) =>
{
var messages = new List<string>() {"Name must start with an underscore"};
return (stringValue.StartsWith("_"), messages);
},
ref this.name))
{
DoSomething(this.name);
}
}
}
Example without validation
private string name;
public string Name
{
get => this.name;
set
{
if (TrySetValue(value, ref this.name))
{
DoSomething(this.name);
}
}
}
AsyncRelayComand<T>
Reusable generic command class that encapsulates ICommand
and allows asynchronous execution.
When used with a Binding
the command will execute asynchronously when an awaitable execute handler is assigned to the command.
// ICommand property
public IAsyncRelayCommand<string> StringAsyncCommand => new AsyncRelayCommand<string>(ProcessStringAsync);
// Execute asynchronously
await StringAsyncCommand.ExecuteAsync("String value");
// Execute synchronously
StringAsyncCommand.Execute("String value");
Profiler
Static helper methods to measure performance e.g. the execution time of a code portion.
// Specify a custom output
Profiler.LogPrinter = (timeSpan) => PrintToFile(timeSpan);
// Measure the average execution time of a specified number of iterations.
TimeSpan elapsedTime = Profiler.LogAverageTime(() => ReadFromDatabase(), 1000);
// Measure the execution times of a specified number of iterations.
List<TimeSpan> elapsedTime = Profiler.LogTimes(() => ReadFromDatabase(), 1000);
// Measure the execution time.
TimeSpan elapsedTime = Profiler.LogTime(() => ReadFromDatabase());
ValueChangedEventArgs<T>
Generic EventArgs
implementation that provides value change information like OldValue
and NewValue
.
// Specify a named ValueTuple as event argument
event EventHandler<ValueChangedEventArgs<(bool HasError, string Message)>> Completed;
protected virtual void RaiseCompleted((bool HasError, string Message) oldValue, (bool HasError, string Message) newValue)
{
this.Completed?.Invoke(this, new ValueChangedEventArgs<(bool HasError, string Message)>(oldValue, newValue));
}
private void OnCompleted(object sender, ValueChangedEventArgs<(bool HasError, string Message)> e)
{
(bool HasError, string Message) newValue = e.NewValue;
(bool HasError, string Message) oldValue = e.OldValue;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
This package has no dependencies.
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.4.1 | 1,326 | 12/4/2019 | |
1.2.1 | 1,194 | 10/18/2019 | |
1.2.0 | 1,160 | 10/13/2019 | |
1.1.13 | 1,167 | 10/12/2019 | |
1.1.12 | 1,197 | 10/3/2019 | |
1.1.11 | 1,233 | 10/3/2019 | |
1.1.10 | 1,165 | 10/3/2019 | |
1.1.9 | 1,202 | 10/3/2019 | |
1.1.8 | 1,195 | 10/3/2019 | |
1.1.7 | 1,180 | 10/3/2019 | |
1.1.6 | 1,162 | 10/3/2019 | |
1.1.5 | 1,227 | 10/1/2019 | |
1.1.4 | 1,212 | 10/1/2019 | |
1.1.0 | 1,188 | 9/29/2019 |
Release