当我这样做时,没有任何反应。 代码背后
public static readonly DependencyProperty prop = DependencyProperty.Register("Prop", typeof(string), typeof(UserControl), null);
public string Prop
{
get { return this.GetValue(prop) as string; }
set { this.SetValue(prop, value); }
}
UserControl的XAML
<TextBox Text="{Binding Path=Prop}"></TextBox>
MainPage的XAML
<xx:MyUserControl Prop="{Binding Name}"></xx:MyUserControl>
答案 0 :(得分:0)
给ElementName
。
Text="{Binding Prop,ElementName =usercontrolname}