-3

Im working with a project in school and I stuck on one thing related with WPF. I have to do ListView with a couple of record and when u click on it will load new window with ListView with more information about the record.

For Example : In first class I have "Name, Surname, Age" when u click on record will load second window with "Date of Birth, Place of Birth etc." declared in second class.

  • how to create this event ? when u click on record u get more info – Davy Jones May 26 '16 at 19:06
  • - http://stackoverflow.com/questions/10207888/wpf-listview-detect-when-selected-item-is-clicked - http://blog.nostatic.org/2007/12/wpf-listview-getting-clicked-item.html - http://matthiasshapiro.com/2008/07/15/clicking-or-doubleclicking-on-an-item-in-a-listview/ - https://msdn.microsoft.com/en-us/library/system.windows.controls.listview(v=vs.110).aspx – Chris Fannin May 26 '16 at 19:17
  • Also, you need code to get help. We can't do your homework. http://stackoverflow.com/help/how-to-ask – Chris Fannin May 26 '16 at 19:18

1 Answers1

0

It Looks like :

        public MainWindow()
    {
        InitializeComponent();

        List = new List<Person>();
        List.Add(new Person("John", "xxx", 20));
        List.Add(new Person("Dimitri", "yyy", 17));
        LP.ItemsSource = List;
    }
    private void DoubleClick(object sender, MouseButtonEventArgs e)
    {
        Window1 win2 = new Window1();
        win2.Show();
    }

Class1:

 class Person
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }

    public Person(string name,string surname,int age)
    {
        Name = name;
        Surname = surname;
        Age = age;
    }
}

Class2:

class Person2
{
    public DateTime Date { get; set; }
    public string Place { get; set; }
    public string Name2 { get; set; }

    public Person2(DateTime date, string place, string name2)
    {
        Date = date;
        Place = place;
        Name2 = name2;
    }
}

Second window:

  public Window1(MainWindow mainwin1)
    {
        mainWindow = mainwin1;

        Person2 c =new Person2(new DateTime(1997, 02, 03), "New York", "Bradley");
        Person2 d = new Person2(new DateTime(1998, 03, 05), "Moscov", "Vladimir");




    }

And all I need to know is how to do: When I click on Dimitry in ListView in second window I will see content only of object d. Same as John but object c.