1
私たちはWindows IoTコア用の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";
}
}