我有一個texbox與屬性綁定。啓用和禁用按鈕
<TextBox Name="txtPrice" Grid.Row="0" Grid.Column="2" MaxLength="8" TabIndex="1"
Text="{Binding Price, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True,
StringFormat= '\{0:#,###.##\}', ConverterCulture=fr-FR}" TextWrapping="Wrap"/>
Private Property _Price As Double
Public Property Price As Double
Get
Return Price
End Get
Set(value As Double)
_Price = Double.Parse(value)
OnPropertyChanged("Price")
End Set
End Property
當我輸入一些字符或文本框爲空,Cmd_Insert,絕不能激活按鈕,但不起作用。 爲什麼? (參見功能CanCmd_Insert())
Public ReadOnly Property Cmd_Insert As ICommand
Get
If _Cm_Insert Is Nothing Then
_Cm_Insert = New RelayCommand(AddressOf Cmd_InsertExe, AddressOf CanCmd_Insert)
End If
Return _Cm_Insert
End Get
End Property
Private Sub Cmd_InsertExe()
UPDATE_Price()
End Sub
Private Function CanCmd_Insert() As Boolean
If IsNumeric(Price) = False Then
Return False
Else
Return True
End If
End Function
http://stackoverflow.com/questions/19364364/mvvm-relaycommand-canexecute 它在C# – Eldho
沒有,爲Vb ...... – Alan392
嘗試設置'在你的綁定模式= TwoWay' – Tomtom