0

我在加载 CheckBox 的已保存设置时遇到问题(选中 True 或 False)。在调用已保存的设置时,它总是从 IsolatedStorage 天气中返回为 True,CheckBox 是否已被选中?请查看随附的代码,如果有人能告诉我我的方式的错误,我将不胜感激。

亲切的问候

将要

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click

'Rem 保存设置'

如果 CheckBox1.IsChecked = True 那么

隔离存储设置.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = True

ElseIf CheckBox1.IsChecked = False Then

IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = False

万一

结束子

    Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click

'Rem 调用保存的设置'

MessageBox.Show("首先选择坦克程序")

CheckBox1.IsChecked = (IsolatedStorageSettings.ApplicationSettings("MyCheckBox"))

结束子

4

1 回答 1

0

这个答案是微软 Silverlight 论坛的 Karmjit Singh 给我的

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) 处理 Button1.Click

  If IsolatedStorageSettings.ApplicationSettings.Contains("MyCheckSettings") Then
     IsolatedStorageSettings.ApplicationSettings("MyCheckSettings") = CheckBox1.IsChecked
  Else
     IsolatedStorageSettings.ApplicationSettings.Add("MyCheckSettings", CheckBox1.IsChecked)
  End If

结束子

Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) 处理 Button2.Click

  Dim x As Boolean?

  IsolatedStorageSettings.ApplicationSettings.TryGetValue(Of Boolean?)("MyCheckSettings", x)
  CheckBox2.IsChecked = x

结束子

于 2012-12-04T14:12:19.793 回答