0
我有如下定義自定義屬性自己的自定義控制:C#WPF引用自定義控制XAML中自定義屬性值
public partial class MyControl : UserControl
{
public CustomProperty X
{
get { return (CustomProperty) GetValue(XProperty); }
set { SetValue(XProperty, value); }
}
public static readonly DependencyProperty XProperty = DependencyProperty.Register(
"X", typeof (CustomProperty), typeof (MyControl), null);
public MyControl()
{
InitializeComponent();
}
}
假設我在XAML中設置X值是這樣的:
<controls:MyControl X="{Binding CustomPropertyValue}" />
我怎樣才能在MyControl
XAML代碼訪問,如果它是這樣定義的X的值:
<UserControl>
<Button Content="<!--What to put here to access X?-->" />
</UserControl>
試試這個''。 – XAMlMAX