如果你想創建可綁定屬性您UserControl-這是做它的方式:你需要
#region MyCustomText
public string MyCustomText
{
get { return GetValue(MyCustomTextProperty) as string; }
set { SetValue(MyCustomTextProperty, value); }
}
public static readonly DependencyProperty MyCustomTextProperty = DependencyProperty.Register("MyCustomText",
typeof(string), typeof(MyUserControl), new System.Windows.PropertyMetadata(null, new PropertyChangedCallback(OnMyCustomTextChanged)));
public static void OnMyCustomTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var control = sender as MyUserControl;
var value = e.NewValue as string;
}
#endregion MyCustomText
發佈一些代碼,如果你想得到一些幫助,至少需要發佈你的XAML和類&proeprty的代碼(去除與該屬性無關的類中的代碼)。 – slugster 2011-12-22 05:02:37
InnerException中是否有任何內容? – tenorsax 2011-12-22 05:04:09