I'm just getting started with WPF. I have TextBox declared in xmal like so:
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=TestComplex.Something, Mode=TwoWay}"/>
In my code behind I have registered the property that I am trying to bind to like so:
public TestComplexObject TestComplex
{
get { return (TestComplexObject)GetValue(TestComplexProperty); }
set { SetValue(TestComplexProperty, value); }
}
public static readonly DependencyProperty TestComplexProperty=
DependencyProperty.Register("TestComplex", typeof(TestComplexObject ), typeof(MainWindow), new UIPropertyMetadata(new TestComplexObject ()));
The TestComplexObject class:
public class TestComplexObject : DependencyObject
{
public string Something
{
get { return (string)GetValue(SomethingProperty ); }
set { SetValue(ExeLocationProperty, value); }
}
public static readonly DependencyProperty SomethingProperty =
DependencyProperty.Register("Something", typeof(string), typeof(TestComplexObject), new UIPropertyMetadata("Test Text"));
}
As you can see I'm trying to bind the TextBox to TestComplex.Something, however when I run this all I get is a xmal parse exception,
"'The invocation of the constructor on type 'EmuRunner.MainWindow' that matches the specified binding constraints threw an exception.' Line number '6' and line position '9"
I really have no idea what I'm doing wrong here, can anyone help?
Thanks in advance.