I'm just starting with WPF (coming from Windows Forms) and I would like to bind a TextBox's text to a class's property and I would like this to be also synchronized with the application's settings (Properties.Settings.Default
). Is it possible to achieve this without code-behind? Currently I have:
<TextBox x:Name="HostnameTextBox" Text="{Binding Path=ConnectModel.Hostname, Mode=TwoWay}" />
which successfully binds to the class's property Hostname. I have stumbled upon Multibinding
but I understand that is not what I want to use in this case, right? How do I make Properties.Settings.Default.Hostname
property synchronized with the TextBox and the class's property, i.e. when the TextBox.Text is changed, then both the user-defined class's property and the settings property will get updated? Is it possible to do that only in the XAML file?
TextBox
?