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

  • SEARCH
  • Home
  • 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 8153361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:59:25+00:00 2026-06-06T15:59:25+00:00

I have a window that uses a viewmodel. This screen contains 2 listviews on

  • 0

I have a window that uses a viewmodel. This screen contains 2 listviews on a screen. The first listview binds to a propery on my viewmodel called projects. This property returns a model as follows

class ProjectsModel
{
    public string ProjectName { get; set; }
    public ObservableCollection<ProjectModel> ProjectDetails { get; set; }
}

In this class the ProjectModel looks like the following

public class ProjectModel
{
    public string ProjectName { get; set; }
    public string ProjectId { get; set; }
    public string ProjectFileId { get; set; }
    public string ProjectSource { get; set; }
    public string ClientCode { get; set; }
    public string JobNumber { get; set; }
}

The first listview shows projectname as i expect but I would like it so that when I click on any of the items, the second listview should display its details of the projectdetails property. It almost appears to work has it shows the first items childrean but I beleive that its not being informed that the selected item of the first listview has changed. Ho can I do this? Any ideas would be appreciated becuase Ive been pulling my hair out for hours now!

This is the xaml

<Window x:Class="TranslationProjectBrowser.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:TranslationProjectBrowser.ViewModels"
    xmlns:local="clr-namespace:TranslationProjectBrowser.Models"
    Title="MainWindow" Height="373" Width="452" Background="LightGray">
<Window.DataContext>
    <vm:ProjectBrowserViewModel></vm:ProjectBrowserViewModel>
</Window.DataContext>
<Window.Resources>
    <ObjectDataProvider x:Key="projectList" ObjectType="{x:Type vm:ProjectBrowserViewModel}" />
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource projectList}}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="176*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="176*" />
        <RowDefinition Height="254*" />
    </Grid.RowDefinitions>
    <DockPanel LastChildFill="True" >
        <TextBlock DockPanel.Dock="Top" Text="Projects" Margin="5,2"></TextBlock>
        <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
        <TextBox Name="ProjectName" Width="140" Margin="5,2" Height="18" FontFamily="Calibri" FontSize="10"></TextBox>
        <Button Height="18" Width="45" HorizontalAlignment="Left" Margin="0,2" FontSize="10" Content="Add" Command="{Binding Path=AddProject}" CommandParameter="{Binding ElementName=ProjectName, Path=Text}"></Button>
        <TextBlock Text="{Binding Path=ErrorText}" VerticalAlignment="Center" Margin="6,2" Foreground="DarkRed"></TextBlock>
        </StackPanel>
        <ListView Name="project" HorizontalAlignment="Stretch" Margin="2" ItemsSource="{Binding Path=Projects}" IsSynchronizedWithCurrentItem="True">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=ProjectName}" Header="Name" Width="200" />
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
    <DockPanel LastChildFill="True" Grid.Row="1" >
        <TextBlock DockPanel.Dock="Top" Text="Project Files" Margin="5,2"></TextBlock>
        <ListView  HorizontalAlignment="Stretch" Margin="2" ItemsSource="{Binding Path=Projects/ProjectDetails}" IsSynchronizedWithCurrentItem="True" >
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=ProjectName}"  Width="200" />
                    <GridViewColumn Header="Job Number" DisplayMemberBinding="{Binding Path=JobNumber}" Width="100" />
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
</Grid>

  • 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-06T15:59:28+00:00Added an answer on June 6, 2026 at 3:59 pm

    Your view models should (at least) implement INotifyPropertyChanged. This is how WPF will know when your selction (or other properties) change and the binding needs to be updated.

    So you should have something like this:

    class ProjectsModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void NotifyPropertyChanged(String PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
    
        public string ProjectName 
        { 
            get
            {
                return _projectName;
            }
            set
            {
                _projectName = value;
                NotifyPropertyChanged("ProjectName");
            }       
        }
        public ObservableCollection<ProjectModel> ProjectDetails 
        { 
            get
            {
                return _projectDetails;
            }
            set
            {
                _projectDetails = value;
                NotifyPropertyChanged("ProjectDetails");
            }
        }
    }
    

    In future versions of the .NET framework this gets a lot easier with the “caller info” attributes (http://www.thomaslevesque.com/2012/06/13/using-c-5-caller-info-attributes-when-targeting-earlier-versions-of-the-net-framework/). But as of today this is usually how it’s done.

    UPDATE

    Ok, so based on your comment you need to bind your ListView’s SelectedItem property to a property on your view model. You can then Bind your second ListView to that property as well. Something like this:

    <ListView ... SelectedItem="{Binding Path=FirstListViewSelectedItem, Mode=TwoWay}" .. >
    

    And then your second list view would be sometihng like this:

    <ListView ... ItemsSource="{Binding Path=FirstListViewSelectedItem.ProjectDetails, Mode=OneWay" .. />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the situation. I have a windows form app that uses an access
I have a window that contains one QTMovieView. How do I make it so
I have a WPF window that uses validation. I created an error template that
I have WPF window that uses a dockpanel and the menu control. I have
I have a WPF window that contains a DataGrid at the bottom half of
I have a page that uses window.print(); which is already printed in the source.
I have a dialog window that uses a URL for its contents { function(){jQuery.ajax({'success':function(html)
I have a page that uses javascript and opens a child window which updates
I have a WPF application that uses a custom window frame. My problem is
I have a WPF app that uses a business object called Visit, it has

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.