views:

53

answers:

1

If I have the following control:

public partial class MyControl : UserControl{
    public string MyControlText{
        get { return MyTextBox.Text; } 
        set { MyTextBox.Text = value; }
    }

    public MyControl(){ ... }
}

How can I bind to the "MyControlText" property when I place the control on one of my pages, like so:

<local:MyControl MyControlText={Binding Path=SomeField} />

Thanks!

+1  A: 

You need to make the property a dependency property. The documentation for the DependencyProperty class shows you how to do this:

http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx#

casperOne