I have a ListView that looks like this:

The combo box is bound to an ObservableCollection of objects of type TfsTask. I would like my controls on the same row to be filled with data contained in the selected item in the combo box when the user change the selection. For example, say that the task “Tests” has a specific Duration value and another Remaining value. If the user selects this task in the combo box, I would like to fill my controls on the row with these values.
Here is the question: How can I bind the controls in the other columns to the selected item of the combo box. When binding directly to a control, you can use its ElementName to do so, but how do you do it in a DataTemplate?
Here is how I define my ListView in XAML. I’ve only put the Task combo box and the Duration text box as an example
<ListView MinHeight="100" Name="m_taskList">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Task" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<ComboBox Name="m_taskName" DisplayMemberPath="Name" SelectedValue="{Binding Path=TaskId, Mode=TwoWay}" SelectedValuePath="Id" ItemsSource="{Binding ElementName=This, Path=TfsTasks}/>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="140" Header="Duration" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid >
<TextBox Text="{Binding ????}" />
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- .... -->
</GridView>
</ListView.View>
</ListView>
It’s working but you must add property in your object in this solution.
Try this:
XAML file:
ViewModel file: