Hi all,

Hopefulle someone outthere can help me identify whay i'm doing wrong. I'm sure it's something simple I have overlooked.
I have the following templates in my xaml.

<Window.Resources>
        <DataTemplate x:Key="ModuleTemplate" >
            <StackPanel Orientation="Vertical">
                <TextBlock Text="{Binding Path=fileName}"/>
                <TextBlock Text="{Binding Path=baseAddress}"/>
                <TextBlock Text="{Binding Path=entryPointAddress}"/>
            </StackPanel>
        </DataTemplate>
        <HierarchicalDataTemplate x:Key="ProcessTemplate" ItemsSource="{Binding Path=Modules}" ItemTemplate="{StaticResource ModuleTemplate}" >
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=id, StringFormat=Pid \{0:d4\}}"/>
                <TextBlock Text=" - "/>
                <TextBlock Text="{Binding Path=processName}"/>
            </StackPanel>
        </HierarchicalDataTemplate>
    </Window.Resources>

The tree view is defined in xaml

<TreeView x:Name="tv_Processes" ItemsSource="{Binding}" ItemTemplate="{StaticResource ProcessTemplate}" />

I have made 2 classes AProcess and AModule

class AProcess : INotifyPropertyChanged
    {
        private string ProcessName;
        public string processName
        {
            get { return ProcessName; }
            set { ProcessName = value; NotifyPropertyChanged("processName"); }
        }

        private int Id;
        public int id
        {
            get { return Id; }
            set { Id = value; NotifyPropertyChanged("id"); }
        }

        public List<AModule> Modules = new List<AModule>();

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
class AModule : INotifyPropertyChanged
    {
        private string FileName;
        public string fileName
        {
            get { return FileName; }
            set { FileName = value; NotifyPropertyChanged("fileName"); }
        }

        private int BaseAddress;
        public int baseAddress
        {
            get { return BaseAddress; }
            set { BaseAddress = value; NotifyPropertyChanged("baseAddress"); }

        }

        private int EntryPointAddress;
        public int entryPointAddress
        {
            get { return EntryPointAddress; }
            set { EntryPointAddress = value; NotifyPropertyChanged("entryPointAddress"); }

        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }

In code behind I fill a

private List<AProcess> processesList = new List<AProcess>();

with information, and I have confirmed that the processesList is filled and the Modules list for each Process, holds the expected data.
And then as the final thing, I bind it to the treeview by

tv_Processes.DataContext = processesList;

The problem is that only the Process information, is shown, no [+] or Modules data is displayed. So what am I doing wrong?

Kind regards
- Henning M

private List<AModule> Modules = new List<AModule>();
        public List<AModule> modules
        {
            get { return Modules; }
            set { Modules = value; NotifyPropertyChanged("modules"); }
        }

Solved the problem..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.