I have a beginer question. Maybe i'm confused and don't fully figure the binding concept out.
I try to use binding, but i do not see any update on a textbox when i change the source value.
XLAM file :
<TextBox IsReadOnlyCaretVisible="True" AutomationProperties.Name="keyIdTextBox" Text="{Binding Path=Name, Mode=oneWay}"/>
...
<Button Content="Open" AutomationProperties.Name="openCloseButton" Click="OpenClose_Click"/>
C# file :
public class Person
{
private string nameValue;
public string Name
{
get { return nameValue; }
set { nameValue = value; }
}
}
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private Person person = new Person { Name = "Bob" };
public MainWindow()
{
InitializeComponent();
this.DataContext = person;
}
private void OpenClose_Click(object sender, RoutedEventArgs e)
{
person.Name = "Lenny";
}
At start, the Textbox is well updated and display "Bob", but when i click on the button to update the value of Name, The textbox does not reflect the value "Lenny". There is no change.
Thank you for you help.