4 Replies - 1125 Views - Last Post: 09 June 2014 - 07:18 AM Rate Topic: -----

#1 mhwmhimhn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-June 14

C#/WPF/XAML beginner question.

Posted 09 June 2014 - 05:04 AM

Hello, i decided to look into c#, WPF & XAML a bit., I've done some UI designing tutorials, but now i would like to learn how to add some functionality to my small application :)

and so I have a beginner question:
I made a treeView and a listView. And i want when i select an item in treeView to display a few items in listView, and when i display the second item in treeView to display different items in listView...

Can anyone link me to a tutorial or just write here how i can do that?

I am using Visual Studio 10 Ultimate.

Is This A Good Question/Topic? 0
  • +

Replies To: C#/WPF/XAML beginner question.

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: C#/WPF/XAML beginner question.

Posted 09 June 2014 - 05:43 AM

Have you worked through even one beginners C# book, cover to cover yet?
What you're asking is very vague and requires you at least understand events. Do you know what an event is in C#?

C# Learning Series, right here on DIC

There are also some tutorials on WPF linked in my signature block

http://www.dreaminco...dow-with-style/
Was This Post Helpful? 0
  • +
  • -

#3 Charles:)   User is offline

  • D.I.C Regular

Reputation: 149
  • View blog
  • Posts: 359
  • Joined: 26-November 09

Re: C#/WPF/XAML beginner question.

Posted 09 June 2014 - 05:44 AM

I assume that each of the objects that you want to display in the tree view contains a collection of objects that will be displayed in the list view. So, roughly speaking, you need to bind ListView.ItemsSource to TreeView.SelectedItem.ItemsCollection
Was This Post Helpful? 1
  • +
  • -

#4 mhwmhimhn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-June 14

Re: C#/WPF/XAML beginner question.

Posted 09 June 2014 - 06:27 AM

View PostCharles:), on 09 June 2014 - 05:44 AM, said:

I assume that each of the objects that you want to display in the tree view contains a collection of objects that will be displayed in the list view. So, roughly speaking, you need to bind ListView.ItemsSource to TreeView.SelectedItem.ItemsCollection


Yes,this sounds to answer my question. Well, i guessed i have to use the 'selected' event. I also figured i have to do something similar to how i can add nodes to treeview: treeView1.Nodes.Add("node1"); But its obvious it doesnt work like that,...

this was my attempt:
        private void TreeViewItem_Selected_1(object sender, RoutedEventArgs e)
        {
            listView1.Items.Add("Wow123");
        }




Any tip how i should do it?
Was This Post Helpful? 0
  • +
  • -

#5 Charles:)   User is offline

  • D.I.C Regular

Reputation: 149
  • View blog
  • Posts: 359
  • Joined: 26-November 09

Re: C#/WPF/XAML beginner question.

Posted 09 June 2014 - 07:18 AM

You don't need the selected event, you just need to bind the two properties I mentioned earlier in markup. Have a look online for WPF data binding tutorials - there are thousands out there. Tree view is possibly one of the more advanced WPF controls, so start with something simpler and work your way up to tree view.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1