you have to inherit DependencyObject to achieve this like
public class MyTextBox : DependencyObject
{
//
// Dependency property for Text
//
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(
"Text",
typeof(string),
typeof(MyTextBox));
//
// Change-aware property
//
public string Text
get { return base.GetValue(TextProperty) as string; }
set { base.SetValue(TextProperty, value); }
}
}
Hope this helps
:)