This is ridiculous. There is no workaround because there is no problem. Your code is working exactly as it should be. If you're recompiling your project over and over then of course you're losing the changes you're making at run time. When your app is deployed though, you won't be recompiling each time the app is run so any changes you make will be permanent. If you want to prove to yourself that this is the case then compile a Release build and run it a couple of times directly from Windows Explorer. You'll see that any changes you make will be persisted to the next session.