I'm new to MVVM.
I have a label in my view that looks like this:
<Label Content="{Binding Path=ClockTime}" />
And my ViewModel looks like:
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
My problem is that the label doesn't update dynamically with the thread in the ViewModel. Is there a simple way to let the View know this value is dynamic?