Well, it depends.
First, I'm not sure if you're talking WPF or Windows Forms, so I'll assume neither.
Second, you are not "binding" anything. You are taking the value of Name
and setting the property Text
equal to this value. You are setting a property. This does not come with any magic side-effects which inextricably links the Name
property to the Text
property.
Third, you can change settings, but until you save them, they are not written back to your app.config. In a Windows Forms app, you'd have to do something like this:
// event handler for the Form.Closed event.
// this.FormClosed += FormClosed;
void FormClosed(object sender, FormClosedEventArgs e)
{
Settings.Default.Name = textBox.Text;
Settings.Default.Save();
}
In WPF, you'd use the normal binding semantics (which means you avoid the hassle of setting all the property values when closing), but you still have to trap for the form closing so you
can Save() the settings.
Binding:
<TextBox
xmlns:lol="clr-namespace:MyApplication.Settings"
Text="{Binding Name, Source={x:Static lol:Default}}" />
The Save() call happens much as with the Forms example, but you don't have to do anything other than call Save().