Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8310951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:38:48+00:00 2026-06-08T19:38:48+00:00

I have a ListView that looks like this: The combo box is bound to

  • 0

I have a ListView that looks like this:

enter image description here

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:38:50+00:00Added an answer on June 8, 2026 at 7:38 pm

    It’s working but you must add property in your object in this solution.

    Try this:

    XAML file:

    <Window x:Class="ListViewCombo.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <ListView MinHeight="100" Name="m_taskList" ItemsSource="{Binding Path=MyItems}">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="140" Header="Task" >
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid HorizontalAlignment="Stretch">
                                        <ComboBox Name="m_taskName" DisplayMemberPath="Name" SelectedItem="{Binding Path=SelectedItem}" SelectedValuePath="ID" ItemsSource="{Binding Path=Items}" />
                                    </Grid>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Width="140" Header="Duration" >
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Grid >
                                <TextBox MinWidth="150" Text="{Binding Path=SelectedItem.Duration}" />
                            </Grid>
                        </DataTemplate>
                     </GridViewColumn.CellTemplate>
                 </GridViewColumn>                   
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
    </Window>
    

    ViewModel file:

    using System.Collections.ObjectModel;
    using Microsoft.Practices.Prism.ViewModel;
    
    namespace ListViewCombo
    {
        class MainViewModel : NotificationObject
        {
            public MainViewModel()
            {
                for (int i = 0; i < 3; i++)
                {
                    ObservableCollection<Task> Source = new ObservableCollection<Task>();
                    for (int j = 0; j < 5; j++)
                    {
                        Source.Add(new Task { ID = i, Name = "Name_" + i, Duration = (i + 2) * 6 + (3 * j) });
                    }
                    MyItems.Add(new TfsTask { ID = i, Items = Source });
                }                        
            }
    
            private ObservableCollection<TfsTask> _myItems = new ObservableCollection<TfsTask>();
            public ObservableCollection<TfsTask> MyItems
            {
                get { return _myItems; }
                set { _myItems = value; RaisePropertyChanged(() => MyItems); }
            }    
        }
    
        public class Task
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public int Duration { get; set; }
        }
    
        public class TfsTask
        {
            public int ID { get; set; }
            public ObservableCollection<Task> Items { get; set; }
            public Task SelectedItem { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView setup in details mode that looks like this: When the
I have am generating a listView that looks like this Now, on the click
I have a ListView that looks like this: Notice how the TextView is getting
I have a ListView bound to XML. The XAML looks like this: <ListView Name=patientsListView
I have form with dateTimeField, and ListView. ListView looks like that: final ListView<String> countryView
I have a model that looks like this: from django.db import models from django.contrib.auth.models
I have an xml formatted document that looks like this: <?xml version=1.0 encoding=windows-1250?> <
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a Listview that looks like the following: checkbox:textview {0 .. n} I
I have a list view that looks like this and that's its code ..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.