I have a wpf window that displays tasks. The user clicks on a task in a TreeView control then other controls (TextBox, ComboBox, etc.) shows the various properties of the selected task. I have implemented this as follows:
1) The TreeView is pupulated by:
ItemsSource="{Binding Source={StaticResource cvsTasks}}"
2) The DataContext for the window is set in code-behind as follows:
Public Class Tasks
Private tsk As Task
....
Private Sub LoadMe(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
DataContext = tsk
....
End Sub
Private Sub SelectTask(sender As Object, e As RoutedPropertyChangedEventArgs(Of Object)) Handles treTasks.SelectedItemChanged
tsk = DirectCast(e.NewValue, Task)
End Sub
....
End Class
3) Each of the task properties use binding as shown below for the Description property:
<TextBox
x:Name="txtDescription"
AcceptsReturn="True"
Text="{Binding Path=Description}">
</TextBox>
and that is what is not working. None of the controls with binding show corresponding value when a TreeView item is selected by the user.
What an I doing wrong?