xaml.cs 中无法访问 ListView 名称

ListView name not access in xaml.cs

我的 xaml 中有 listView 的数据透视表。 ListView 的名称为“NoteItems: 我不能写完整的 xaml 代码,所以我把 link 给了文档。 https://drive.google.com/open?id=1wcbvdex25zV8_AYWjLfLC9fs9T1XsSo9

但是xaml.cs有错误"The name "NoteItems"does not exist in the current context" in this string:

            NoteItems.DragOver += OnStepsListViewDragOver;
        (NoteItems.ItemsSource as INotifyCollectionChanged).CollectionChanged += OnStepsCollectionChanged;

您的项目驻留在 ItemTemplate 中,因此您无法通过 CodeBehind 或范围外的任何地方访问它。

这样想:在设计时,没有项目,在运行时有 n!

那么您希望您的消息来源访问哪个项目? -> 不可能。

可以 的工作是你命名你的枢轴并逐步找到项目..但我需要更多关于你的 xaml 结构的信息来提供一个明确的答案。