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