![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Icommand >From the Expressions interactive designer there is a Csharp example which I have put thru a VB converter - I am stuck on the following (last) error triggered by Implements ICommand Hope some one can help with a simple line of code , have spent sometime already on the rest of the stuff, Thanks Casey Error-- Error 4 Class 'DelegateCommand' must implement 'Event CanExecuteChanged(sender As Object, e As EventArgs)' for interface 'System.Windows.Input.ICommand'. Source--- Imports System Imports System.Windows.Input Namespace Awdataclass ''' ''' DelegateCommand is a simplified version of WPF's ICommand. You can wrap one of these around any method, ''' and thus bind any Command on any WPF object to your method. ''' ''' DelegateCommand also supports an IsEnabled property you can use to turn the command on and off. ''' Public NotInheritable Class DelegateCommand Implements ICommand ' Type signature of the method that DelegateCommand works with - returns void, no arguments. Public Delegate Sub SimpleEventHandler() ' Remember the method so we can call it when it's time. Private handler As SimpleEventHandler ' Maintain our enabled state. Private isEnabled_Renamed As Boolean = True ' Simple constructor: Just pass in the method that needs to be called when the command executes. Public Sub New(ByVal handler As SimpleEventHandler) Me.handler = handler End Sub #Region "ICommand implementation" ' Executing the command is as simple as calling that method we were handed on creation. Private Sub Execute(ByVal arg As Object) Implements ICommand.Execute Me.handler() End Sub ' Saying whether we can execute the command. Private Function CanExecute(ByVal arg As Object) As Boolean Implements ICommand.CanExecute Return Me.IsEnabled End Function ' This is the event that WPF's command architecture listens to so it knows when to update the UI ' on command enable/disable. Public Event CanExecuteChanged As EventHandler #End Region ' Public visibility of our isEnabled flag - note that when it is set, we need to raise the event ' so that WPF knows to update any UI that uses this command. Public Property IsEnabled() As Boolean Get Return Me.isEnabled_Renamed End Get Set(ByVal value As Boolean) Me.isEnabled_Renamed = value Me.OnCanExecuteChanged() End Set End Property ' Simple event propagation that makes sure someone is listening to the event before raising it. Private Sub OnCanExecuteChanged() If Not Me.CanExecuteChangedEvent Is Nothing Then RaiseEvent CanExecuteChanged(Me, EventArgs.Empty) End If End Sub End Class End Namespace |
My System Specs![]() |