Image UriSource and Data Binding

WPF has built-in converters for certain types. If you bind the Image’s Source property to a string or Uri value, under the hood WPF will use an ImageSourceConverter to convert the value to an ImageSource. So <Image Source=”{Binding ImageSource}”/> would work if the ImageSource property was a string representation of a valid URI to an … Read more

How to make Databinding type safe and support refactoring?

Note this answer uses WinForm and was written before C# had ‘NameOf()’ Thanks to Oliver for getting me started I now have a solution that both supports refactoring and is type safe. It also let me implement INotifyPropertyChanged so it copes with properties being renamed. It’s usage looks like: checkBoxCanEdit.Bind(c => c.Checked, person, p => … Read more

ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1

Disclaimer: The fix below is intended to solve a specific problem with some dependencies conflict, mostly databinding issues can cause this error but are only a consequence of wrong XML or code and the solution below will not work in this case. Double check your XML/code correctness before trying the below solution. This is a … Read more

How to detect broken WPF Data binding?

In .NET 3.5 it was introduced a new way to specifically output tracing information about specific data bindings. This is done through the new System.Diagnostics.PresentationTraceSources.TraceLevel attached property that you can apply to any binding or data provider. Here is an example: <Window x:Class=”WpfApplication1.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:diag=”clr-namespace:System.Diagnostics;assembly=WindowsBase” Title=”Debug Binding Sample” Height=”300″ Width=”300″> <StackPanel> <TextBox Name=”txtInput” /> … Read more