vb.net INotifyPropertyChanged 及 ICommand
作者:互联网
Imports System.ComponentModel ''' <summary> ''' 属性变化后通知UI ''' </summary> ''' <remarks></remarks> Public Class NotificationObject Implements INotifyPropertyChanged Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged Public Sub RaisePropertyChanged(PropertyName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(PropertyName)) End Sub End Class ''' <summary> ''' 绑定命令属性 ''' </summary> ''' <remarks></remarks> Class DelegateCommand Implements ICommand Public ExecuteCommand As Action(Of Object) = Nothing Public CanExecuteCommand As Func(Of Object, Boolean) = Nothing Public Function CanExecute(parameter As Object) As Boolean Implements ICommand.CanExecute If IsNothing(Me.CanExecuteCommand) Then Return True Else Return Me.CanExecute(parameter) End If End Function Public Event CanExecuteChanged(sender As Object, e As EventArgs) Implements ICommand.CanExecuteChanged Public Sub Execute(parameter As Object) Implements ICommand.Execute If Not IsNothing(Me.ExecuteCommand) Then Me.ExecuteCommand(parameter) End If End Sub Public Sub RaiseCanExcuteChanged() If Not IsNothing(Me.CanExecuteCommand) Then RaiseEvent CanExecuteChanged(Me, EventArgs.Empty) End If End Sub End Class
标签:ICommand,Me,vb,End,Sub,Object,Implements,net,Public 来源: https://www.cnblogs.com/bug01/p/10971630.html