C#C
C#2y ago
Alex

✅ TreeViewItem Expanded event in MVVM

I want to execute command LoadSubDirectories when TreeViewItem is expanded, but I don't understand how can I do it in MVVM, where should I bind command?
    <DockPanel>
        <TreeView ItemsSource="{Binding Items}">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate 
                    DataType="{x:Type models:NavigationPaneItem}" 
                    ItemsSource="{Binding Children}"
                >
                    <TextBlock Text="{Binding Name}"/>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
Was this page helpful?