Metro(XAML/C#):检测安装和/或首次运行 [英] Metro (XAML/C#): detect installation and/or first run

查看:49
本文介绍了Metro(XAML/C#):检测安装和/或首次运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XAML/C#中创建Metro应用程序时,如何检测自安装(或潜在升级)以来首次安装或首次运行该应用程序的时间?我需要利用这个机会来确保我的数据库架构正确,并可能同步一些基本数据.

When creating Metro applications in XAML/C#, how do I detect when the application is first installed or run for the first time since installation (or potentially upgrade)? I need to use this opportunity to ensure that my database schema is correct and potentially synchronise some base data.

我曾希望可以从OnLaunched方法中的LaunchActivatedEventArgs中选择它,但是似乎没有可以使用的KindPreviousExecutionState的有效值.

I had hoped that I could pick this up from the LaunchActivatedEventArgs within the OnLaunched method, but there does not seem to be a valid value for the Kind or PreviousExecutionState that I can use.

谢谢.

推荐答案

应用启动时,将名为"AppHasBeenStarted"的设置或其他内容写入LocalSettings.如果尚未写入设置,则表明您之前尚未启动过应用程序.您可以通过将其设置为"AppVersion"并编写应用程序的版本来进行改进.这样,您的应用可以通过将存储的版本与其自己的版本进行比较来检测升级.

When your app starts, write a setting called "AppHasBeenStarted" or something to LocalSettings. If the setting has not already been written, you know your app hasn't been started before. And you could improve on this, by making it "AppVersion", and writing the app's version. This way your app can detect upgrades by comparing the stored version with its own version.

这篇关于Metro(XAML/C#):检测安装和/或首次运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆