FastBindings.WPF
1.1.1
See the version list below for details.
dotnet add package FastBindings.WPF --version 1.1.1
NuGet\Install-Package FastBindings.WPF -Version 1.1.1
<PackageReference Include="FastBindings.WPF" Version="1.1.1" />
paket add FastBindings.WPF --version 1.1.1
#r "nuget: FastBindings.WPF, 1.1.1"
// Install FastBindings.WPF as a Cake Addin #addin nuget:?package=FastBindings.WPF&version=1.1.1 // Install FastBindings.WPF as a Cake Tool #tool nuget:?package=FastBindings.WPF&version=1.1.1
#FastBinding vs AsyncFastBinding
IDEA
One of the bottlenecks where WPF application loses performance is in the bindings. Unfortunatelly binding access to ViewModel properties through reflection. The existing mechanism is a monolith that is closed for changes from outside. It can be improved if access to ViewModel properties is done directly, for example, through some contract:
interface IAccessProperties { object GetProperty(string name); void SetProperty(string name, object value); }
REQUIREMENTS
To use new FastBinding we need to implement described contract in ViewModel. Or use class CommonViewModel<T> as parent for ViewModel, if it is possible, or implement it like it is done in CommonViewModel<T>. Under the hood CommonViewModel works with properties through a cached tree expression.
- The most effective way --
using FastBindings.Common; public class MainWindowViewModelV2 : BaseViewModel { public override object? GetProperty(string propertyName) { switch (propertyName) { case nameof(Text): return Text; } return null; }
public override void SetProperty(string propertyName, object? value)
{
switch (propertyName)
{
case nameof(Text):
if (value?.GetType() == Text.GetType())
Text = (string)value;
break;
}
}
}
- Simple and fast way -- using FastBindings.Common; public class MainWindowViewModel : CommonBaseViewModel<MainWindowViewModel>{ .....}
- If the parent class already exists --
using FastBindings.Common; using FastBindings.Interfaces; public class MainWindowViewModel : <ParentClass>, IPropertyAccessor { private PropertyHolder<MainWindowViewModel> _holder; public MainWindowViewModel() { _holder = new PropertyHolder<MainWindowViewModel>(); } public object? GetProperty(string propertyName) { return _holder.GetProperty(propertyName); } public void SetProperty(string propertyName, object? value) { _holder.SetProperty(propertyName, value); } }
[Sources]
Property Sources allows to use one or simultaneously few objects and devider between sources ; It supports not only familiar from ViewModels long paths (Outgoing.Notification.Message), but framework properties and events. P.S. Without forward or back converter target will be interact only with first source in list
Formats for framework classes in Sources:
$[[control_name].dependencyProperty(event)] — control on the target level $[[ancsestorType/ancestorsLevel].dependencyProperty(event)] — parent control above target $[[this].dependencyProperty(event)] — target itself
[DataSourcePath]
By default for ViewModel we using DataSource from target element. DataSourcePath property allows us to use DataSource from another place
Formats:
<control_name> (panel)- on the target level <ancsestorType/ancestorsLevel>(ListBox/1)— parent control above
[Converter], [ConverterPath], [ConverterName]
Now converter can be both at StaticResources level (property Converter) and at ViewModel level (ConverterPath), but not simultaneously at the same time. Priority goes from staticResource level converter to ViewModel level converter. And ViewModel level converter requires that converter has concrete name (property ConverterName). User is not required to create simultaneously back and forward initialization. P/S Using a converter guarantees that you can receive any exceptions that the ViewModel property might throw. [ConverterPath] formats see [DataSourcePath] formats
[CacheStrategy]
Property CacheStrategy. It is option to improve efficiency during interaction with ViewModels. None Simple. If user uses few bindings from one ViewModel property(no long form), during update this property it will be read only once
[Notification], [NotificationPath], [NotificationName]
NotificationFilter (from Source to Target, Target to Source) Now it allows us to skip update from Source to Target, Target to Source. [NotificationPath] - path to ViewModel with implemented INotificationFilter For AsyncBinding we receive events not only before and after the update.
[FallbackValue]
If viewModel property returns Exception, WPF will use this value instead
p/s ASYNC FAST BINDING works asynchronously and can operate with Task<?> viewModel property.
Examples: <TextBox Text="{custom:FastBinding Mod.MyProperty;MyProperty1;$[[RRR].ActualWidth], CacheStrategy=Simple, ConverterName=Test, ConverterPath=Mod}" /> <TextBlock Text="{custom:FastBinding Mod.MyProperty;MyProperty2;$[[ListBox/1].ActualWidth], CacheStrategy=Simple,ConverterName=Test, ConverterPath=Mod}" /> <TextBox Text="{custom:AsyncFastBinding Mod.Test, NotificationName =UU, NotificationPath=Mod}" />
NEXT RELEASE
Reactive binding from framework properties and events.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.5
- No dependencies.
-
net5.0
- 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.