Search code examples
wpfvb.netvisual-studio-2012application-settings

Are WPF Application Settings automatically saved by default?


Are WPF Application Settings automatically saved by default when exit?

I just added a boolean to my application settings (by default is setted to false). I want to set it to true when application is running and next time when I open it again, to be false. I don't want to save my application settings. I want to be static for that boolean.

It is saving automatically?

When I used to work with VB.NET Winforms, there was a setting in Application tab, named "Save my.settings on shutdown". But, how is in WPF?

I use Visual Studio 2012, Vb.NET WPF application

Thank you


Solution

  • Are settings saved automatically? No, you have to explicit invoke the Save method upon each settings class.

    Since you mention that you have multiple windows, then i think the quick and dirty way would be to override the OnExit Method in App:

    Class Application
        Protected Overrides Sub OnExit(ByVal e As ExitEventArgs)
            MySettings.Default.Save()
            MyBase.OnExit(e)
        End Sub
    End Class