无法在VB中实现ICommandSource

有没有人试过用VB实现ICommandSource? Microsoft提供的示例是在C#中,由于VB不允许隐式实现,因此这个界面在VB中无法实现! http://msdn.microsoft.com/en-us/library/ms771361.aspx     
已邀请:
这取决于您要在哪个类上实现它。如果您在自己的类(实现接口的地方)中引入了Command,CommandParameter和CommandTarget属性,则可以像任何其他接口一样实现它:
Public ReadOnly Property Command() As ICommand
  Implements ICommandSource.Command
  Get
    ' implementation goes here
  End Get
End Property
顺便说一句,您仍然可以使用DP来实现:Implements指令位于CLR属性上,并且不会干扰getter和setter的“请勿触摸”实现。 如果要在其上实现它的类已经具有(继承)Command,CommandParameter和CommandTarget属性,并且您希望接口实现重用这些属性,则需要使用新名称创建新属性,将它们声明为接口实现并返回他们到现有的属性
Public ReadOnly Property ICommandSource_Command() As ICommand
  Implements ICommandSource.Command
  Get
    Return Me.Command  ' the existing implementation that can't be made implicit
  End Get
End Property
    

要回复问题请先登录注册