MVVM을 처음 사용했습니다.MVVM의 ViewModel에서 업데이트되는 값에 바인딩 하시겠습니까?
I는 다음과 같습니다 내보기에 라벨이 있습니다
<Label Content="{Binding Path=ClockTime}" />
을 그리고 내 ViewModel에 보이는 같은 :
Public Class MainWindowViewModel
Inherits ViewModelBase
Dim strClockTime As String
Dim dstDispatcherTimer As New Windows.Threading.DispatcherTimer
Public Sub New()
AddHandler dstDispatcherTimer.Tick, AddressOf TimeDelegate
dstDispatcherTimer.Interval = New TimeSpan(0, 0, 1)
dstDispatcherTimer.Start()
End Sub
Private Sub TimeDelegate(ByVal sender As Object, ByVal e As System.EventArgs)
strClockTime = DateTime.Now.ToString("dddd, dd MMMM yyyy h:mm:ss tt")
End Sub
Public ReadOnly Property ClockTime As String
Get
Return strClockTime
End Get
End Property
End Class
내 문제 레이블이 스레드와 동적으로 업데이트하지 않는다는 것입니다 ViewModel에서. 보기가이 값이 동적임을 쉽게 알 수있는 간단한 방법이 있습니까? 당신은 토드이 당신이 뭔가를보고 ViewModelBase이 필요한 것처럼 당신이 당신의 코드를 업데이트해야합니다 말에 확장하려면 클럭 타임