C#中的简单依赖属性和UserControl问题

我的最终目标是从UserControl在XAML中的调用中公开我在UserControl中的TextBoxText值。

  

将使用TextBox的文本呈现UserControl

我一直在使用各种示例工作,但我总是最终得到“在UserControl类型中找不到属性SetCustomText”

如何执行此操作的示例:

       
 public partial class MyUserControl1 : UserControl { // The dependency property which will be accessible on the UserControl public static readonly DependencyProperty MyTextPropertyProperty = DependencyProperty.Register("MyTextProperty", typeof(string), typeof(MyUserControl1), new UIPropertyMetadata(String.Empty)); public string MyTextProperty { get { return (string)GetValue(MyTextPropertyProperty); } set { SetValue(MyTextPropertyProperty, value); } } public MyUserControl1() { InitializeComponent(); } }