有沒有人試圖用VB實現ICommandSource? 微軟提供的例子是用C#編寫的,因爲VB不允許隱式實現,所以這個接口就像VB中無法實現的一樣!無法在VB中實現ICommandSource
http://msdn.microsoft.com/en-us/library/ms771361.aspx
有沒有人試圖用VB實現ICommandSource? 微軟提供的例子是用C#編寫的,因爲VB不允許隱式實現,所以這個接口就像VB中無法實現的一樣!無法在VB中實現ICommandSource
http://msdn.microsoft.com/en-us/library/ms771361.aspx
這取決於你想實現它什麼課。如果你在介紹自己的類的命令,CommandParameter和CommandTarget屬性(你在哪裏實現接口),你可以實現它像任何其他接口:
Public ReadOnly Property Command() As ICommand
Implements ICommandSource.Command
Get
' implementation goes here
End Get
End Property
您仍然可以使用一個DP爲順便說一句,實現,實現指令是在CLR屬性上,不會干涉getters和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
檢查此[SO鏈接](http://stackoverflow.com/questions/1685976/how-can-i-create-an-interface-in-vbnet-與隱-implimentations)。所以你可能需要在c#中做到這一點。 –