如何从主页面设置绑定到UserControl内部的TextBox?

时间:2016-04-16 11:11:52

标签: c# xaml win-universal-app

当我这样做时,没有任何反应。 代码背后

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>

1 个答案:

答案 0 :(得分:0)

ElementName

Text="{Binding Prop,ElementName =usercontrolname}