简体   繁体   English

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

[英]How to set Binding to TextBox that is inside of UserControl from mainpage?

When I'm doing this nothing happens. 当我这样做时,什么也没发生。 Code behind 后面的代码

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); }
}

XAML of UserControl UserControl的XAML

<TextBox Text="{Binding Path=Prop}"></TextBox>

XAML of MainPage 主页的XAML

<xx:MyUserControl Prop="{Binding Name}"></xx:MyUserControl>

给出ElementName

Text="{Binding Prop,ElementName =usercontrolname}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM