asked on
Imports System.Windows.Input
Public Class RelayCommand
Implements ICommand
Private _isEnabled As Boolean
Private ReadOnly _handler As Action
Public Sub New(handler As Action)
_handler = handler
End Sub
Public Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged
Public Property IsEnabled As Boolean
Get
Return _isEnabled
End Get
Set(value As Boolean)
If value <> _isEnabled Then
_isEnabled = value
RaiseEvent CanExecuteChanged(Me, EventArgs.Empty)
End If
End Set
End Property
Public Function CanExecute(parameter As Object) As Boolean Implements ICommand.CanExecute
Return IsEnabled
End Function
Public Sub Execute(parameter As Object) Implements ICommand.Execute
_handler()
End Sub
End Class
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.ComponentModel.DataAnnotations
Public Class ProductionBandsawWelding
Public Property WeldingComplete As RelayCommand
Public Sub New()
SetupCommands()
End Sub
Private Sub SetupCommands()
WeldingComplete = New RelayCommand(AddressOf WeldedNew)
WeldingComplete.IsEnabled = True
End Sub
Public Sub WeldedNew()
MsgBox("In Welded New")
End Sub
End Class
<StackPanel Grid.Row="6" Orientation="Horizontal" DataContext="{Binding Mode=OneWay, Source={StaticResource ProductionWeldingObjectDataProvider}}">
<Button Name="OrderCompleteButton" Content="Order Complete" Command="{Binding WeldingComplete}" CommandParameter="OrderCompleteButton.tag" />
</StackPanel>