Showing ConnectionString entry in Messagebox
MessageBox.Show(Properties.Settings.Default.ConnectionString);
First make a namespace reference to the Properties namespace.If your application name is WpfApplication1 it is xmlns:props=”WpfApplication1.Properties”.
Then in the Binding set source as the Default property available in the class Settings.Since it is static you have to use the x:Static binding extension.
Finally the path is ConnectionString which is the settings entry name.
Putting it altogether.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="WpfApplication1.Window1" x:Name="Window" xmlns:props="clr-namespace:WpfApplication1.Properties"> <Grid x:Name="LayoutRoot"> <TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Source={x:Static props:Settings.Default},Path=ConnectionString}"> </TextBox> </Grid> </Window>
No comments:
Post a Comment