This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
57 lines (43 loc) · 1.84 KB
/
MainWindow.xaml.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Imports System.Windows
Imports System.Windows.Input
Imports DevExpress.Xpf.RichEdit
Namespace RichEditBindCommandsToStandardControlsWpf
Public Partial Class MainWindow
Inherits Window
Public Sub New()
Me.InitializeComponent()
End Sub
End Class
Public Class CustomRichEditUICommand
Implements ICommand
Private Shared ReadOnly myCommandField As CustomRichEditUICommand = New CustomRichEditUICommand("MyCommand")
Public Shared ReadOnly Property MyCommand As CustomRichEditUICommand
Get
Return myCommandField
End Get
End Property
Private ReadOnly commandName As String
Public Sub New()
End Sub
Protected Friend Sub New(ByVal commandName As String)
Me.commandName = commandName
End Sub
'#Region "ICommand Members"
Public Custom Event CanExecuteChanged As System.EventHandler Implements ICommand.CanExecuteChanged
AddHandler(ByVal value As System.EventHandler)
End AddHandler
RemoveHandler(ByVal value As System.EventHandler)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
End RaiseEvent
End Event
Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute
Return True
End Function
Public Sub Execute(ByVal parameter As Object) Implements ICommand.Execute
If Not Equals(commandName, "MyCommand") Then Throw New System.ApplicationException("Unknown command")
Call MessageBox.Show("Custom command is executed" & Microsoft.VisualBasic.Constants.vbCrLf & "RichEditControl.Text: " & CType(parameter, RichEditControl).Text, "MyCommand")
End Sub
'#End Region
End Class
End Namespace