{"id":27430850,"url":"https://github.com/alex141/calcbinding","last_synced_at":"2025-05-15T10:00:50.090Z","repository":{"id":24208009,"uuid":"27599626","full_name":"Alex141/CalcBinding","owner":"Alex141","description":"Advanced WPF Binding which supports expressions in Path property and other features","archived":false,"fork":false,"pushed_at":"2023-09-27T01:15:42.000Z","size":355,"stargazers_count":656,"open_issues_count":37,"forks_count":80,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-15T03:10:06.408Z","etag":null,"topics":["binding","c-sharp","wpf","xaml"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alex141.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-12-05T16:20:33.000Z","updated_at":"2025-04-21T01:43:45.000Z","dependencies_parsed_at":"2023-10-20T16:32:59.409Z","dependency_job_id":null,"html_url":"https://github.com/Alex141/CalcBinding","commit_stats":{"total_commits":224,"total_committers":5,"mean_commits":44.8,"dds":0.0758928571428571,"last_synced_commit":"fc01ad59b80650883133b8586a1e79ff121af669"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex141%2FCalcBinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex141%2FCalcBinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex141%2FCalcBinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex141%2FCalcBinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alex141","download_url":"https://codeload.github.com/Alex141/CalcBinding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319715,"owners_count":22051072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding","c-sharp","wpf","xaml"],"created_at":"2025-04-14T15:16:46.299Z","updated_at":"2025-05-15T10:00:49.433Z","avatar_url":"https://github.com/Alex141.png","language":"C#","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=GH8PLP5ZFAJ8Y","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=WYDUQS5M7QNNQ"],"categories":[],"sub_categories":[],"readme":"# CalcBinding\r\n\r\nCalcBinding is an advanced Binding markup extension that allows you to write calculated binding expressions in xaml, without custom converters. CalcBinding can automaticaly perfom bool to visibility convertion, different algebraic operations, inverse your expression and more. CalcBinding makes binding expressions shorter and more user-friendly. [Release notes](#release-notes)\r\n\r\n## Install\r\n\r\nCalcBinding is available at [NuGet](https://www.nuget.org/packages/CalcBinding/). You can install package using:\r\n```\r\nPM\u003e Install-Package CalcBinding \r\n```\r\n\r\n## Overview\r\nFollowing example shows xaml snippets with standart Binding and with CalcBinding in very simple case:\r\n\r\n### Before:\r\n\r\n```xml\r\n\u003cLabel\u003e\r\n  \u003cLabel.Content\u003e\r\n  \u003cMultiBinding Conveter={x:StaticResource MyCustomConverter}\u003e \r\n    \u003cBinding A/\u003e \r\n    \u003cBinding B/\u003e \r\n    \u003cBinding C/\u003e \r\n  \u003c/MultiBinding\u003e\r\n  \u003c/Label.Content\u003e\r\n\u003c/Label\u003e \r\n```\r\n\r\n(without MyCustomConveter declaration and referencing to it in xaml)\r\n\r\n### After:\r\n\r\n```xml\r\n\u003cLabel Content=\"{c:Binding A+B+C }\" /\u003e\r\n```\r\n\r\n### Key features and restrictions:\r\n\r\n1. One or **many** source properties in Path with many available operators: [description](#1-source-properties-and-operators)\r\n\r\n  ```xml\r\n  \u003cLabel Content=\"{c:Binding A*0.5+(B.NestedProp1/C - B.NestedProp2 % C) }\" /\u003e\r\n  ```\r\n  ```xml\r\n  \u003cc:Binding 'A and B or C' /\u003e\r\n  ```\r\n2. One or **many static properties** in Path: [description](#2-static-properties)\r\n\r\n  ```xml\r\n  \u003cTextBox Text=\"{c:Binding 'local:StaticClass.Prop1 + local:OtherStaticClass.NestedProp.PropB + PropC'}\"/\u003e\r\n  ```\r\n  ```xml\r\n  \u003cButton Background=\"{c:Binding '(A \u003e B ? media:Brushes.LightBlue : media:Brushes.White)'}\"/\u003e\r\n  ```\r\n3. Properties and methods of class **System.Math** in Path: [description](#3-math-class-members)\r\n\r\n  ```xml\r\n  \u003cTextBox Text=\"{c:Binding 'Math.Sin(Math.Cos(A))'}\"/\u003e\r\n  ```\r\n4. **Enum** types like constants or source properties in Path: [description](#4-enums)\r\n\r\n  ```xml\r\n  \u003cTextBox Text=\"{c:Binding '(EnumValue == local:CustomEnum.Value1 ? 10 : 20)'}\"/\u003e\r\n  ```\r\n5. **Automatic inversion** of binding expression if it's possible: [description](#5-automatic-inversion-of-binding-expression)\r\n\r\n  ```xml\r\n  \u003cTextBox Text = \"{c:Binding 'Math.Sin(A*2)-5'}\"/\u003e {two way binding will be created}\r\n  ```\r\n6. Automatic two way convertion of **bool** expression **to Visibility** and back if target property has such type: [description](#6-bool-to-visibility-automatic-convertion)\r\n\r\n  ```xml\r\n  \u003cButton Visibility=\"{c:Binding !IsChecked}\" /\u003e \r\n  \u003cButton Visibility=\"{c:Binding IsChecked, FalseToVisibility=Hidden}\" /\u003e\r\n  ```\r\n7. Other features such as **string and char constants support** and other: [description](#7-other-feautures)\r\n\r\n8. General restrictions: [description](#8-general-restrictions)\r\n\r\n# Documentation\r\n\r\n## 1. Source properties and operators\r\n\r\nYou can write any algebraic, logical and string expressions, that contain source property pathes, strings, digits, all members of class Math and following operators:\r\n\r\n```\r\n\"(\", \")\", \"+\", \"-\", \"*\", \"/\", \"%\", \"^\", \"!\", \"\u0026\u0026\",\"||\",\r\n\"\u0026\", \"|\", \"?\", \":\", \"\u003c\", \"\u003e\", \"\u003c=\", \"\u003e=\", \"==\", \"!=\"};\r\n```\r\nand ternary operator in form of **'bool_expression ? expression_1 : expression_2'**\r\n\r\nOne should know, that xaml is generally xml format, and xml doesn't support using of following symbols when setting attribute value: **\u0026, \u003c**. Therefore, CalcBinding supports following aliases for operators that contain these symbols:\r\n\r\n| operator | alias | comment |\r\n| -------- |:-----:| :-----:|\r\n| \u0026\u0026 | and |  |\r\n| \\|\\|      | or      |   not nessesary, just for symmetry |\r\n| \u003c | less      |     |\r\n| \u003c= | less= |        |\r\n\r\n### Examples\r\n\r\n#### Algebraic \r\n```xml\r\n\u003cTextBox Text=\"{c:Binding A+B+C}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding A-B-C}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding A*(B+C)}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding 2*A-B*0.5}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding A/B, StringFormat={}{0:n2} --StringFormat is used}\"/\u003e {with string format}\r\n\u003cTextBox Text=\"{c:Binding A%B}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 1) ? 10 : 20'}\"/\u003e {ternary operator}\r\n```\r\n#### Logic\r\n```xml\r\n\u003cCheckBox Content=\"!IsChecked\" IsChecked=\"{c:Binding !IsChecked}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding 'IsChecked and IsFull'}\"/\u003e {'and' is equvalent of '\u0026\u0026'}\r\n\u003cTextBox Text=\"{c:Binding '!IsChecked or (A \u003e B)'}\"/\u003e {'or' is equvalent of '||', but you can leave '||'}\r\n\u003cTextBox Text=\"{c:Binding '(A == 1) and (B less= 5)'}\"/\u003e {'less=' is equvalent of '\u003c='}\r\n\u003cTextBox Text=\"{c:Binding (IsChecked || !IsFull)}\"/\u003e\r\n```\r\n\r\n### Restrictions:\r\n\r\n1. Identifiers that make up the source property path, should be separated from operator ':' by any operator or delimititer (single quote, space etc.) in ternary operator:\r\n\r\n#### right:\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?IsChecked : IsFull}\"/\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?IsChecked :!IsFull}\"/\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2) ? IsChecked :4 + IsFull}\"/\u003e \u003c!-- right --\u003e\r\n```\r\n\r\n#### wrong:\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?IsChecked:IsFull}\"/\u003e \u003c!-- wrong --\u003e\r\n```\r\n\r\nThat restricition is caused by path analyzer work that finds [static properties](#2-static-properties)\r\n\r\n## 2. Static properties\r\n\r\n  Beginning with version 2.3 CalcBinding supports static properties in binding expression. You can write pathes that begin with static property of any class and have any number of properties following behind static property. CalcBinding uses following syntax of static property path declaration:\r\n  \r\n  **'xmlNamespace:Class.StaticProperty.NestedProperty'** etc.\r\n  \r\nwhere:\r\n  \r\n  1. **xmlNamespace** - usual xml namespace that is mapped to normal namespace in a header of xaml file with other namespaces definitions.   \r\n  \r\n  2. **Class** - name of class that exists in namespace whereto xmlNamespace is mapped\r\n  \r\n  3. **StaticProperty** - static property of class **Class**\r\n  \r\n  4. **.NestedProperty etc** - chain of properties following behind **StaticProperty**\r\n  \r\n### Examples:  \r\n  ```xml\r\n  \u003cTextBox Text=\"{c:Binding 'local:Class.NestedProp.Prop1 + local:OtherStaticClass.PropB + PropC'}\"/\u003e\r\n  ```\r\n  ```xml\r\n  \u003cButton Background=\"{c:Binding '(A \u003e B ? media:Brushes.LightBlue : media:Brushes.White)'}\"/\u003e\r\n  ```\r\n  \r\n  where **local** and **media** are defined in a header of xaml file:\r\n  ```xml\r\n  \u003c\u003cUserControl x:Class=\"WpfExample.FifthPage\"\r\n             xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\r\n             xmlns:local=\"clr-namespace:WpfExample\"\r\n             xmlns:media =\"clr-namespace:System.Windows.Media;assembly=PresentationCore\"\u003e\r\n     ...\r\n  \u003c/UserControl\u003e\r\n  ```  \r\n  \r\n### Restrictions\r\n1. As for non-static property pathes for static property pathes following rule is applied: you should put any delimiter or operator between ':' operator of ternary operator and identifiers (namespace or property) that make up static property path:\r\n\r\n#### right:\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:Class.Prop1 : local:Class.Prop2}\"/\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:OtherClass.IsChecked :!local.OtherClass.IsFull}\"/\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2) ? local:Class.A :4 + local:Class.B}\"/\u003e \u003c!-- right --\u003e\r\n```\r\n\r\n#### wrong:\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:Class.Prop1: local:Class.Prop2}\"/\u003e \u003c!-- wrong --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:OtherClass.IsChecked:local.OtherClass.IsFull}\"/\u003e \u003c!-- wrong --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2) ? local:Class.A:4+local:Class.B}\"/\u003e \u003c!-- wrong --\u003e\r\n```\r\n\r\n## 3. Math class members\r\n\r\nYou can use in path property any members of System.Math class in native form as if you are writing usual C# code:\r\n\r\n```xml\r\n\u003cTextBox Text=\"{c:Binding Math.Sin(A*Math.PI/180), StringFormat={}{0:n5}}\"/\u003e\r\n\u003cTextBox Text=\"{c:Binding A*Math.PI}\" /\u003e\r\n```\r\n\r\n## Restrictions\r\n1. Although CalcBinding supports static properties, Math class is a standalone feature that was created and used before static properties were supported. For this reason you shouldn't use static property syntax with members of Math class. \r\n\r\n#### right:\r\n```xml\r\n\u003cTextBox Text=\"{c:Binding A*Math.PI}\" /\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding Math.Sin(10)+20}\" /\u003e \u003c!-- right --\u003e\r\n```\r\n\r\n#### wrong:\r\n```xml\r\n\u003cxmlns:sys=\"clr-namespace:System;assembly=mscorlib\"\u003e\r\n...\r\n\u003cTextBox Text=\"{c:Binding A*sys:Math.PI}\" /\u003e \u003c!-- wrong --\u003e\r\n\u003cTextBox Text=\"{c:Binding sys:Math.Sin(10)+20}\" /\u003e \u003c!-- wrong --\u003e\r\n```\r\n\r\n## 4. Enums\r\n\r\nBeginning with version 2.3 CalcBinding supports Enums expressions in binding expression. You can write enum values or properties that have Enum type (static properties too). CalcBinding uses following syntax of declaration enum value:\r\n  \r\n  **'xmlNamespace:EnumClass.Value'**\r\n  \r\nwhere:\r\n  \r\n  1. **xmlNamespace** - usual xml namespace that is mapped to normal namespace in a header of xaml file with other namespaces definitions.\r\n  \r\n  2. **EnumClass** - name of enum class that exists in namespace whereto xmlNamespace is mapped\r\n  \r\n### Examples:  \r\n  ```xml\r\n  \u003cCheckBox Content=\"Started\" IsChecked=\"{c:Binding 'State==local:StateEnum.Start'}\" /\u003e\r\n  ```\r\n  ```xml\r\n  \u003cButton Background=\"{c:Binding 'EnumValue == local:MyEnum.Value1 ? media:Brushes.Green : media:Brushes.Red'}\"/\u003e\r\n  ```\r\n  \r\n  where \r\n  \r\n  1. **local** and **media** are defined in a header of xaml file:\r\n    ```xml\r\n    \u003c\u003cUserControl x:Class=\"WpfExample.FifthPage\"\r\n               xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\r\n              xmlns:local=\"clr-namespace:WpfExample\"\r\n              xmlns:media =\"clr-namespace:System.Windows.Media;assembly=PresentationCore\"\u003e\r\n      ...\r\n    \u003c/UserControl\u003e\r\n    ```  \r\n    \r\n  2. **StateEnum, MyEnum** - custom Enums\r\n  \r\n  3. **StateEnum.Start, MyEnum.Value1** - values of custom Enums\r\n  \r\n  4. **Brushes** - standart class with static Brush properties\r\n  \r\n  5. **Brushes.Green, Brushes.Red** - static properties of class Brushes\r\n  \r\n### Restrictions\r\n1. As for static property pathes for Enum constants following rule is applied: you should put any delimiter or operator between ':' operator of ternary operator and identifiers (namespace or property) that make up Enum path:\r\n\r\n#### right:\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?sys:Visibility.Visible : sys:Visibility.Hidden}\"/\u003e \u003c!-- right --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:MyEnum.Value1 : local.MyEnum.Value2}\"/\u003e \u003c!-- right --\u003e\r\n```\r\n\r\n#### wrong:\r\n\r\n```\u003cxml\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?sys:Visibility.Visible:sys:Visibility.Hidden}\"/\u003e \u003c!-- wrong --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:MyEnum.Value1: local.MyEnum.Value2}\"/\u003e \u003c!-- wrong --\u003e\r\n\u003cTextBox Text=\"{c:Binding '(A == 2)?local:MyEnum.Value1 :local.MyEnum.Value2}\"/\u003e \u003c!-- wrong --\u003e\r\n```\r\n\r\n## 5. Automatic inversion of binding expression\r\n\r\n  For examle, you have to create two way binding from viewModel with double property A and Content property of TextBox.\r\n  TextBox.Content depends on property 'A' by following formula:\r\n    'Math.Sin(A*2)-5'\r\n  \r\n  All you have to do is to write:\r\n  \r\n  ```xml\r\n  \u003cTextBox Text = \"{c:Binding 'Math.Sin(A*2)-5'}\"\u003e\r\n  ```\r\n\r\nCalcBinding recognizes that this expression has inversed expression 'A = Math.Asin(TextBox.Content + 2) / 2' and will use this expression for convertion dependency property TextBox.Text to property A of ViewModel when Text of textBox changes.\r\n\r\nPrevious expression equivalents to following usual code:\r\n\r\n```xml\r\n\u003cTextBox Text = \"{Binding Path=A, Conveter={x:StaticResource MyMathConverter}\"\u003e\r\n```\r\n\r\n```C#\r\npublic class MyMathConverter : IValueConverter\r\n{\r\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\r\n        {\r\n          var source = (int)value;\r\n          return Math.Sin(source*2)-5;\r\n        }\r\n        \r\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\r\n        {        \r\n          var res = Double.Parse(value);\r\n          return (int)(Math.Asin(res + 5) / 2);\r\n        }\r\n}\r\n```\r\n\r\n### Restrictions of creating inversed expression\r\n1.  Binding must include only one property path (static or non-static) and only one entry of it\r\n\r\n2. Binding can contain only following operators and methods:\r\n\r\n  ```\r\n  \"+\", \"- (binary)\", \"*\", \"/\", \"Math.Sin\", \"Math.Cos\", \"Math.Tan\", \"Math.Asin\", \r\n  \"Math.Acos\", \"Math.Atan\",\"Math.Pow\", \"Math.Log\", \"!\", \"- (unary)\"};\r\n  ```\r\n\r\n## 6. Bool to Visibility automatic convertion\r\n\r\nCalcBinding recognizes if dependency property with Visibility type binds to bool expression. If it's true then bool expression is converted to Visibility automaticaly.\r\n\r\nObsiously **true** expression result is converted to **Visibility.Visible**\r\n\r\nProperty **FalseToVisibility** of CalcBinding specifies state in which **false** expression result is converted. Flag can have one of the following values:\r\n\r\n1. FalseToVisibility.Collapsed (default)\r\n2. FalseToFisibility.Hidden\r\n\r\n### Examples\r\n```xml\r\n\u003cButton Content=\"TargetButton\" Visibility=\"{c:Binding HasPrivileges, FalseToVisibility=Collapsed}\"/\u003e\r\nor just\r\n\u003cButton Content=\"TargetButton\" Visibility=\"{c:Binding !HasPrivileges}\"/\u003e\r\n\r\n\u003cButton Content=\"TargetButton\" Visibility=\"{c:Binding !HasPrivileges, FalseToVisibility=Hidden}\"/\u003e\r\n```\r\n\r\nAutomatic inversion is distributed to this convertion too. If dependency property equals to Visibility.Visible, then it's converted to **true**, otherwise - to **false**.\r\n\r\n## 7. Other feautures\r\n\r\n### String, Char and SingleQuotes mode\r\n\r\nXaml is markup language based on xml language and xml doesn't support double-quotes signs in attribute values. Xaml doesn't support double-quotes too, futhermore it has problems with supporting single-quote character in Path value: in one expressions is works, in other - no. In order to give an opportunity of writing the most compact and readable string constants in the Path (\\\\', or \\\u0026apos; or \\\u0026quot;) CalcBinding doesn't make difference between double and single quotes - all quotes are considered as double quotes by defaults. For example:\r\n\r\n```xml\r\n\u003cTextBox Text=\"{c:Binding (Name + \\' \\' + Surname)}\" /\u003e\r\n\u003cTextBox Text=\"{c:Binding (IsMan?\\'Mr\\':\\'Ms\\') + \\' \\' + Surname + \\' \\' + Name}\"/\u003e\r\n```\r\n\r\nHowever, in this case we loose the ability of supporting Char constants. Therefore beginning with version 2.3 CalcBinding has new property - SingleQuotes. If property is true, CalcBinding considers that all quotes - double and single, are single quotes. So \\\\'A\\\\' and \\\u0026quot;A\\\u0026quot; are Char symbols in that mode. If property is false, then single and double quotes are considered as double quotes, it is variant by defaults. So \\\\'A\\\\' and \\\u0026quot;A\\\u0026quot; are String constants in that mode. Examples of Char supporting:\r\n\r\n```xml\r\n\u003cTextBox Text=\"{c:Binding 'Symbol == \u0026quot;S\u0026quot;?4:5', SingleQuotes=True}\"/\u003e {can't use no \\' nor \u0026apos; symbols because of xaml compiler generates error when parses == operator}\r\n```\r\nwhere Symbol - Char property.\r\n\r\n#### Restrictions:\r\n1. Simultaneous using of Char and String constants is not supported in this version.\r\n\r\n### TemplateBinding\r\nAlthouth CalcBinding hasn't yet analog for TemplateBinding, as temporary solution you can write as follow: \r\n```xml\r\n\u003cButton Content=\"Button\" Width=\"100\"\u003e\r\n    \u003cButton.Template\u003e\r\n        \u003cControlTemplate\u003e\r\n            \u003cTextBox Width=\"{c:Binding Width+10, RelativeSource={RelativeSource TemplatedParent}}\"/\u003e\r\n        \u003c/ControlTemplate\u003e\r\n    \u003c/Button.Template\u003e\r\n\u003c/Button\u003e \r\n```\r\nSetting RelativeSource property to TemplatedParent value makes CalcBinding similar to TemplateBinding\r\n\r\n## 8. Tracing\r\n  \r\n  All calcbinding traces are disabled by default due to huge amount of trace messages in some scenarios (see [bug 44](https://github.com/Alex141/CalcBinding/issues/44)).\r\n  \r\n  To enable traces, you need to specify minimal tracing level. Add this code to your app.config file to see all Information or higher priority logs:\r\n\r\n```xml\r\n  \u003csystem.diagnostics\u003e\r\n    \u003cswitches\u003e\r\n      \u003cadd name=\"CalcBindingTraceLevel\" value=\"Information\"/\u003e\r\n    \u003c/switches\u003e\r\n  \u003c/system.diagnostics\u003e\r\n```\r\n  \r\n  Other available tracing levels:\r\n  * All,\r\n  * Off,\r\n  * Critical,\r\n  * Error,\r\n  * Warning,\r\n  * Information,\r\n  * Verbose,\r\n  \r\n  For more information, go to msdn: [SourceSwitch](https://docs.microsoft.com/ru-ru/dotnet/api/system.diagnostics.sourceswitch?view=netframework-4.8)\r\n  \r\n## 9. General restrictions\r\n\r\n1. Nullable value types doesn't supported in reverse binding (e.g. mode OneWayToSource)\r\n\r\n2. CalcBinding doesn't support your custom conveters at all now. If you need this feature, create new issue and put your using scenario in order to I can see that it is necessary\r\n\r\n3. In path expression you can't use any methods of .Net classes except of Math class.\r\n\r\n## What is inside?\r\n\r\nCalcBinding uses DynamicExpresso library to parse string expression to Linq Expression and compiled expression tree for binding.\r\nDynamicExpresso is in fact a fork of DynamicLinq library, with many advantages and bug fixes compared with DynamicLinq (e.x. floating point parsing depending on CurrentCulture damn bug). \r\n\r\nString expression is parsed only one time, when binding is initialized. In init section CalcBinding analyzer finds tokens in path expression: property path, static property path, Math expression and Enum expression. When binding is triggered first time, special binding converter replaces each property path and static propert path with variable of appropriate type and call DynamicExpresso to compile expression into delegate that takes new variables. \r\n\r\nWorking with the compiled expression increases speed of binding compared with parsing of string expression each time. On the development machine, these times are 0.03s for parsing each time and 0.001-0.003 s for working with the compiled expression\r\n\r\n### Notes \r\n  1. Enum constants are using in expression for Dynamic Expresso directly, with collection of types of known Enums.\r\n  2. Binding for collections (ListView, ListBox, DataGrid etc) are created as many times how many times it were declared in xaml. For example, if you have ListView with 10000 elements, and each element have template consisting of 5 controls which are all binded then only 5 Binding instances would be created.\r\n  3. If one or more property pathes changes type of resulting property then compiling expression is recompilied.\r\n\r\n# Q\u0026A\r\n```\r\n1. I wrote logical expression A \u0026\u0026 B, A \u003c B, A \u003c= B, but my xaml doesn't compile, what's wrong?\r\n```\r\nAs Xaml is generally xml format, some symbols are denied and one should use it's aliases instead os its. See operators aliases table in section [Source properties and operators](#1-source-properties-and-operators)\r\n```\r\n2. I wrote string expression A + \" some text\", but my xaml doesn't compile, what's wrong?\r\n```\r\nIn markup extension we can't use double quotes, so we can use single quotes and backslash for escaping \\\\' or xml escape symbol \\\u0026quot;. See section [String, Char and SingleQuotes mode](#string-char-and-singlequotes-mode)\r\n```\r\n3. Can I use CalcBinding instead of TemplateBinding?\r\n```\r\nYes, you can, but with setting RelativeSource property, see section [TemplateBinding](#templatebinding)\r\n\r\n# Release notes\r\n\r\n## version 2.5.2.0\r\n\r\n* Add FallbackValue [#37](https://github.com/Alex141/CalcBinding/issues/37), \r\n* Disable traces by default, add traces configuration [#44](https://github.com/Alex141/CalcBinding/issues/44). Documentation: [Tracing](#8-tracing)\r\n  \r\nThanks to [metal450](https://github.com/metal450) for waiting 2 years!!\r\n\r\n## version 2.5.1.0\r\n  \r\n* Support \u003cb\u003e.net core 3.0! \u003c/b\u003e\r\n  \r\nPR [#57](https://github.com/Alex141/CalcBinding/pull/57). Thanks to [bigworld12](https://github.com/bigworld12) !\r\n  \r\n## version 2.4.0.0\r\n\r\n* Fix performance issues: add parsed expressions cache \r\n\r\nbug [#56](https://github.com/Alex141/CalcBinding/issues/56). Thanks to jtorjo!\r\n  \r\n## version 2.3.0.1\r\n\r\n* Add support of implicitly and explicitly castable to boolean types in BoolToVisibilityConverter \r\n\r\n(bug [#53](https://github.com/Alex141/CalcBinding/issues/53). Thanks to rstroilov!)\r\n\r\n\r\n\r\n## version 2.3.0.0\r\n\r\n* Add support of [Static properties](#2-static-properties), [Enums](#4-enums), [Char constants](#string-char-and-singlequotes-mode). \r\n\r\nPossible problems of switching to this version from older versions:\r\n\r\nIt is important that names of properties, classes and namespaces that make up sources pathes, would be separated from operator ':' in ternary operator (at least one space or parenthesis) for this version. See section [Restrictions](#restrictions)\r\n\r\n## version 2.2.5.2\r\n\r\n* fix defect with exception in binding to readonly properties with BindingMode.Default (#41) (thanks to maurosampietro and earthengine!)\r\n\r\nPossible problems of switching to this version from older versions:\r\n\r\nIn older versions CalcBinding creates Binding with BindingMode.TwoWay by default. In new version Binding is created with BindingMode.Default by default (which is more right and standart Binding is doing quite so). Mode = Default means that each DependencyProperty can manage personally in which mode it should be translated. For example, DefaultMode of TextBox.Text is TwoWay, but Label.Content, TextBox.Visibility - OneWay. \r\nIf you used in you applications TwoWay Binding with DependencyProperty that has DefaultMode = BindingMode.OneWay and you didn't specify Mode=TwoWay in xaml so you need to do it in this version for same work.\r\n\r\nexample.\r\n```xml\r\n\u003cButton Content=\"TargetButton\" Visibility=\"{c:Binding !HasPrivileges}\"/\u003e\r\n```\r\nIn older version it creates BindingMode.TwoWay binding, in new version it creates BindingMode.Default, which translated by Label.Visibility in BindingMode.OneWayMode. If you need to stay on BindingMode.TwoWay then just specify it:\r\n\r\n```xml\r\n\u003cButton Content=\"TargetButton\" Visibility=\"{c:Binding !HasPrivileges, Mode=TwoWay}\"/\u003e\r\n```\r\n  \r\n## version 2.2.5.1\r\n\r\n* fix defect with special characters in const strings in path expression (thanks to xmedeko!)\r\n\r\n## version 2.2.5.0\r\n\r\n* add support of properties that contain digits in there names (thanks to halllo!)\r\n\r\n## version 2.2.4.0\r\n\r\n* add support of 'null' values: objects that can be null, nullable value types. For nullable value types there are resctrictions, see restrictions page\r\n\r\n## version 2.2.3.0\r\n\r\n* add 'not' alias for '!' operator\r\n\r\n## version 2.2.2.0\r\n\r\n* version for .net 4.0\r\n\r\n## version 2.1.2.0\r\n\r\n* RelativeSource in multibinding support\r\n\r\n## version 2.1.1.0\r\n\r\n* bug fixes\r\n\r\n## version 2.1.0.0\r\n\r\n* DataTrigger support\r\n* bug fixes\r\n\r\n## version 2.0.0.0\r\n\r\n* support of two way binding, support of automatic invert binding expression and realization inverted binding from dependency property to source\r\n* Math class support\r\n* support of nested properties (in nested view-models)\r\n* bug fixes\r\n\r\n## version 1.0.0.0\r\n\r\n* binding support\r\n* supported features: binding/multibinding, algebraic, logic, string and ternary operators\r\n* support of bool to visibility convertion (two way)\r\n\r\n# Donation\r\n\r\nIf you like this project you are welcome to support it!\r\n\r\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;USD:\r\n\r\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;[![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=GH8PLP5ZFAJ8Y)\r\n\r\n\u0026nbsp;\r\n\r\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;RUB:\r\n\r\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;[![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=WYDUQS5M7QNNQ)\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex141%2Fcalcbinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falex141%2Fcalcbinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex141%2Fcalcbinding/lists"}