3

I've come across an interesting situation whilst starting to work with the WPF framework.

I have the following code to create an ObservableCollection of type Foo

ObservableCollection<Foo> myFoo;

Foo has the following Properties:

  • String Name
  • String Folder
  • ObservableCollection Items

Both Name and Folder have the OnPropertyChanged event implemented (Items already uses ObservableCollection so I believe no additional implementation work is necessary).

For every item within myFoo I would like to show the following:

  • Name
  • Folder
  • Every value of FileInfo.FullName within Items.

e.g.

  • Test Name 1
  • Test Folder 1
  • FileA.JPG
  • FileB.JPG
  • FileC.PNG

  • Test Name 2

  • Test Folder 2
  • FileD.JPG
  • FileE.JPG
  • FileF.JPG

I've implemented the binding for the Name and Folder properties, however I'm not too sure on how I should implement binding the value of each Items.FileInfo.FullName occurance.

Would I need to implement a Converter?

Many thanks for your help.

Jamie Keeling
  • 9,806
  • 17
  • 65
  • 102

1 Answers1

3

You need to look into HierarchicalDataTemplate. Maybe start with this question.

Community
  • 1
  • 1
Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222