Before I begin with my question I've been reading every link imaginable on the subject and I'm still stuck.
I am putting together a WPF using C# and Visual Studio. I want to have a TextBox retain text in it when the application to shut down and restarted and that the text is read/write because the text will change often.
I've set up a new .settings file and have it in my Properties folder in my project. I created this using the nifty grid where I can make a name, type, and value etc etc.
So far after several several hours I think I'm closer yet am not sure. This is the Designer.cs -
namespace PRX.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class saveData : global::System.Configuration.ApplicationSettingsBase {
private static saveData defaultInstance = ((saveData)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new saveData())));
public static saveData Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("mainSource")]
public string Setting {
get {
return ((string)(this["Setting"]));
}
set {
this["Setting"] = value;
}
}
}
}
The .settings file is called saveData.settings and I have the table set up as Name: Setting , Type: String, Value: mainSource. The Scope is set to user. This is in the Properties folder just like the default Settings.settings files.
The TextBox in questions has this connected like so:
<ScrollViewer VerticalScrollBarVisibility="Auto">
<TextBox DockPanel.Dock="Top" Margin="10" Background="Black" Name="tb1" TextWrapping="Wrap" AcceptsReturn="True" Text="{Binding Source={x:Static p:saveData.Default}, Path=Default.Setting, Mode=TwoWay}"></TextBox>
</ScrollViewer>
And for good measure here's how it looks like in the app.config:
<PRX.saveData>
<setting name="Setting" serializeAs="String">
<value>mainSource</value>
</setting>
</PRX.saveData>
</userSettings>
I know it's connected to the .Settings file because when I debug the value 'mainSource' is present in the Textbox
I've read over dozen links on the subject but most notably these two:
http://blogs.msdn.com/b/patrickdanino/archive/2008/07/23/user-settings-in-wpf.aspx http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx
I am especially confused with this, the documentation I am reading seems very straight-forward yet I can't seem to grasp it. Any help is supremely appreciated. Thanks