wpf binding upwards: bind to view model property inside nested uiElement
问题 I have a WPF project with a view model and some nested UI elements. Here is the (relevant section of) XAML: <UserControl> // DataContext is MyVM (set programmatically) <TreeView ItemsSource="{Binding Trees}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Subtrees}"> <StackPanel> <ListView ItemsSource="{Binding Contents}" SelectedValue="{Binding SelectedContent}" // won't work: Tree has no such property SelectionMode="Single"/> </StackPanel> </HierarchicalDataTemplate