我在加载CheckBox的保存设置时遇到问题(Checked True或False)。在调用已保存的设置时,它总是从IsolatedStorage天气返回True,CheckBox是否已被检查?请看附带的代码,如果有人能告诉我我的方式错误,我将不胜感激。
亲切的问候
将
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
'Rem Save Settings'
如果CheckBox1.IsChecked = True则
IsolatedStorageSettings.ApplicationSettings(“MyCheckBox”)= CheckBox1.IsChecked = True
ElseIf CheckBox1.IsChecked = False然后
IsolatedStorageSettings.ApplicationSettings(“MyCheckBox”)= CheckBox1.IsChecked = False
结束如果
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click
'Rem调用已保存的设置'
MessageBox.Show(“首先选择坦克程序”)
CheckBox1.IsChecked =(IsolatedStorageSettings.ApplicationSettings(“MyCheckBox”))
End Sub
答案 0 :(得分:0)
本回答是由来自Microsoft Silverlight Forunm的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
End Sub
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
End Sub