【发布时间】:2017-03-14 19:21:59
【问题描述】:
我们有一个适用于 Windows IoT Core 的 UWP,我们需要保存一些设置,但即使应用程序停止或 IoT 设备重新启动,这些设置也必须有效。
我拥有的代码如下,当应用程序打开时它工作得很好,如果我在 XAML 页面之间切换,但在应用程序停止时不起作用,就像变量不存在一样。
static class Global
{
public static Windows.Storage.ApplicationDataContainer localSettings { get; set; }
public static Windows.Storage.StorageFolder localFolder { get; set; }
}
private void Btn_Inciar_Config_Click(object sender, RoutedEventArgs e)
{
if (TxtDeviceKey.Text != String.Empty || TxtDeviceName.Text != String.Empty || Txt_Humedad_Config.Text != String.Empty || Txt_Intervalo_Config.Text != String.Empty || Txt_Temperatura_Ambiente_Config.Text != String.Empty || Txt_Temperaura_Config.Text != String.Empty)
{
Windows.Storage.ApplicationDataCompositeValue composite =
new Windows.Storage.ApplicationDataCompositeValue();
composite["GlobalDeviceKey"] = TxtDeviceKey.Text;
composite["GlobalDeviceName"] = TxtDeviceName.Text;
composite["GlobalTemperature"] = Txt_Temperaura_Config.Text;
composite["GlobalHumidity"] = Txt_Humedad_Config.Text;
composite["GlobalTemperatureRoom"] = Txt_Temperatura_Ambiente_Config.Text;
composite["GlobalInterval"] = Txt_Intervalo_Config.Text;
localSettings.Values["ConfigDevice"] = composite;
Lbl_Error.Text = "";
Frame.Navigate(typeof(MainPage));
}
else
{
Lbl_Error.Text = "Ingrese todos los campos de configuracion";
}
}
【问题讨论】:
标签: c# .net uwp .net-core windows-10-iot-core