如果您使用的是CLRProperty,那麼您不能用於綁定目的。
public partial class MyCustomControl : UserControl
{
public MyCustomControl()
{
InitializeComponent();
}
public string MyCLRProperty { get; set; }
public string MyProperty
{
get { return (string)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(string), typeof(MyCustomControl));
}
<my:MyCustomControl MyProperty="{Binding BindingProperty}"
MyCLRProperty="MyCLRProperty"/>
並不完全正確,取決於你使用的是什麼模式,你用的是什麼作爲源/目標。 – 2011-05-09 15:40:06
它不工作,不應該是一個AttachedProperty? – 2013-02-26 08:46:07