Sunday, March 25, 2012

Accessing App.Config Properties From XAML



Problem:

How to access user settings stored in app.config file from XAML?

Accessing app.config from XAML

Solution:

First we need to add reference to Properties in our XAML file.
xmlns:p="clr-namespace:MyExample.Properties"
And this is how we use it:
<TextBox Name="serverNameTextBox" 
         Grid.Column="1" Grid.Row="0"
         Text="{Binding Source={x:Static p:Settings.Default}, 
                                Path=ServerName, Mode=OneWay}">
</TextBox>
Hope it will save your time.

No comments:

Post a Comment