Skip to content

Instantly share code, notes, and snippets.

@isidore
Last active August 29, 2015 14:03
Show Gist options
  • Save isidore/17921d43012ff77829f7 to your computer and use it in GitHub Desktop.
Save isidore/17921d43012ff77829f7 to your computer and use it in GitHub Desktop.
WpfBindings
Binding myBinding = new Binding(TestViewModel.MyPropertyPropertyName);
WpfBindingsAssert.BindsWithoutError(viewModel, () =>
{
// ... create control and initalize bindings
// (This will happen once the reporting and logging has been setup)
var textBox = new TextBox();
textBox.SetBinding(TextBox.TextProperty, myBinding);
return textBox;
});
/************************************************
If this fails you will get an exception like:
System.Windows.Data Error: 40 : BindingExpression path error: 'MyProperty' property not found on 'object' ''TestViewModel' (Hashcode)'.
BindingExpression:Path=MyProperty
DataItem='TestViewModel' (Hashcode)
target element is 'TextBox' (Name='')
target property is 'Text' (type 'String')
*************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment