Let's say that I have a custom WPF control and couple of textboxes on it. In code behind of my custom control I have couple of properties which are references to objects in other control. For example I have a sth like this
public MyClass myObject
{
get
{
return MyObject
}
}
MyClass have a property Name. Is it possible to bind property Name to textBox.Text ??
I konow that I can do sth like that in XAML
<TextBox>
<TextBox.Text>
<Binding Path="" />
</TextBox.Text>
</TextBox>
But how can I pass data from myObject to Path value ??
I've been experimenting with bindings but it seems that sometimes my textbox doesn't refresh/update Text property. I mean sometimes textbox refresh(I thin开发者_如何学Pythonk) and I see new value but sometimes nothing happens (despite the fact that I modified data )
Assuming that the DataContext is the same as your Control. The path will be
Path="myObject.MyPropery"
or for short
<TextBox Text="{Binding myObject.MyProperty}" />
精彩评论