简体   繁体   中英

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

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

XAML of MainPage

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

给出ElementName

Text="{Binding Prop,ElementName =usercontrolname}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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