Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/keyboarddrummer/wpfbindingsfromexpressions

Generates WPF bindings from C# Expression trees.
https://github.com/keyboarddrummer/wpfbindingsfromexpressions

Last synced: 23 days ago
JSON representation

Generates WPF bindings from C# Expression trees.

Awesome Lists containing this project

README

        

# WPFBindingsFromExpressions
Allows you to write WPF bindings using C# expression trees.

Both OneWay and TwoWay bindings can be generated, depending on what's possible given the original expression tree:

ExpressionToBindingParser.TwoWay(() => Child.InputText).Apply(TextBox, TextBox.TextProperty);
ExpressionToBindingParser.OneWay(() => "You wrote: " + Child.InputText).Apply(Label, ContentProperty);

By using an expression tree that takes an argument, bindings that use a context value are created:

var isCheckedColumn = new DataGridCheckBoxColumn();
isCheckedColumn.Binding = ExpressionToBindingParser.OneWay((Item item) =>
item.ChildItem.IsChecked && item.IsChecked).ToBindingBase();

##### Details
The expression tree is parsed by the framework and converted into a WPF BindingBase.
From the expression tree, as much as possible is converted into WPF paths,
while the remaining part of the expression tree is moved into a WPF value converter.
By putting the expression tree into WPF paths,
WPF will track these paths using INotifyPropertyChange and update the bound controls when required.