Thursday, 26 April 2012

WPF binding to application settings

It is advisable to bind to a view model, but it is possible to bind to the application settings:

<Application x:Class="Toolkit.Shell.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:properties="clr-namespace:Toolkit.Shell.Properties">

<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding Source={StaticResource Settings}, Path=Default.SetPublisherHost}" />

and when the application closes

Shell.Properties.Settings.Default.Save();

No comments:

Post a comment