CollectionViewSource:TreeView 未更新,ViewModel 看起来不错

CollectionViewSource: TreeView not updating, ViewModel looking good

我正在尝试在 TestExplorerControl 中填充 TreeView:

直到现在我都不需要使用 CollectionViewSource,所以我使用 this tutorial 来掌握如何将我的 ObservableCollection<TestMethod> 分组到 XAML 中,并使用我的树视图分组 - 我在 <UserControl.Resources> 中实现了数据模板,因为我希望最终允许用户更改测试重新分组方式的灵活性:

<CollectionViewSource x:Key="OutcomeGroupViewSource" Source="{Binding Model.Tests}">
  <CollectionViewSource.GroupDescriptions>
    <PropertyGroupDescription PropertyName="Result.Outcome" />
  </CollectionViewSource.GroupDescriptions>
</CollectionViewSource>

<DataTemplate x:Key="TestMethodTemplate" DataType="{x:Type local:TestMethod}">
  <StackPanel Orientation="Horizontal">
    <Image .../>
    <TextBlock .../>
  </StackPanel>
</DataTemplate>

<HierarchicalDataTemplate x:Key="OutcomeTemplate" DataType="{x:Type CollectionViewGroup}"
  ItemsSource="{Binding Items}" 
  ItemTemplate="{StaticResource TestMethodTemplate}">
  <StackPanel Orientation="Horizontal">
    <Image ../>
    <TextBlock ../>
    <TextBlock ../>
  </StackPanel>
</HierarchicalDataTemplate>

然后我有实际的标记 <TreeView>:

<TreeView Grid.Row="2"
  ItemsSource="{Binding Source={StaticResource OutcomeGroupViewSource}, Path=View.Groups}"
  ItemTemplate="{StaticResource OutcomeTemplate}" />

此标记有什么问题,导致 TreeView 更新失败? ViewModel 显然有我需要显示的所有数据(断点在当前行,黄色):

找到了。它是树视图中 ItemsSource 绑定的 Path

ItemsSource="{Binding Source={StaticResource OutcomeGroupViewSource}, Path=View.Groups}"

Path=View.Groups 满足 IntelliSense,但错误。

它必须是 Path=Groups,即使设计者无法解析 属性: