-2

我需要禁用我的按钮 while dzien=0,并启用 while dzien >0

当我启动应用程序时,day 是 0 还是 102938129038 都没有关系,按钮仍然处于禁用状态。我的代码有什么问题?

Imports System.IO.IsolatedStorage
Partial Public Class Page1
Inherits PhoneApplicationPage
Private dzien As Integer
Public Sub New()
    InitializeComponent()
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
    IsolatedStorageSettings.ApplicationSettings("dzien") = dzien
    Try
        dzien = CInt(IsolatedStorageSettings.ApplicationSettings("dzien"))
    Catch ex As KeyNotFoundException
        dzien = 0
    End Try
    If dzien = 0 Then
        dzien = dzien + 1
    End If
    NavigationService.Navigate(New Uri("/2.xaml", UriKind.Relative))
End Sub
Private Sub Class_1_loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
    If dzien = 0 Then
        Button2.IsEnabled = False
    Else
        Button2.IsEnabled = True
    End If

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

    dzien = dzien + 1

    NavigationService.Navigate(New Uri("/2.xaml", UriKind.Relative))
End Sub
End Class

我不确定是否

If dzien = 0 Then
    dzien = dzien + 1
End If

运作良好,并且

dzien = dzien + 1
4

2 回答 2

3
Private Sub Class_1_loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If dzien = 0 Then
   Button2.Enabled = False
Else 
   Button2.Enabled = True
End Sub
于 2012-10-10T12:59:22.207 回答
0

我不确定,但如果.ENABLED.ISENABLED不一样,我认为这就是问题所在......

于 2012-10-11T10:43:00.947 回答