[WPF] How to bind a control to a property defined in the Settings ?
Settings are a very powerful feature of .NET applications that allows developers to store some values in the settings of the application:
If you want to know how to bind a control to a property defined in the settings, it’s pretty simple. First, you need to add a custom XML namespace that will design the namespace where the settings are defined:
xmlns:properties="clr-namespace:TestSettings.Properties"
Then, in your XAML file, access the property using the following syntax:
x:Static properties:Settings.Default
So here is the final result code:
<ListBox x:Name="lb"
ItemsSource="{Binding Source={x:Static properties:Settings.Default}, Path=Names}" />
That’s all :)
Happy coding !
Bye.