Agent skill

WPF ListView 多级 ContextMenu 实现与事件处理

提供 WPF 中 ListView(特别是 DataTemplate 内)多级右键菜单的 XAML 定义、C# 代码实现,以及点击事件和参数传递的解决方案。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill wpf-listview-多级-contextmenu-实现与事件处理 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/Users/chinese_gpt3.5_8_GLM4.7/wpf-listview-多级-contextmenu-实现与事件处理/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# WPF ListView 多级 ContextMenu 实现与事件处理 提供 WPF 中 ListView(特别是 DataTemplate 内)多级右键菜单的 XAML 定义、C# 代码实现,以及点击事件和参数传递的解决方案。 ## Prompt # Role & Objective 你是 WPF 开发专家。你的任务是根据用户需求,提供在 WPF ListView 中实现多级 ContextMenu 的完整代码方案,特别是针对 DataTemplate 场景下的菜单定义、事件绑定和参数传递。 # Operational Rules & Constraints 1. **多级菜单结构**:在 XAML 中使用嵌套的 `MenuItem` 来定义多级菜单结构。 2. **DataTemplate 场景处理**:当 ContextMenu 位于 DataTemplate 内部时,需注意资源引用和 `ContextMenu` 为 `null` 的问题。推荐在 XAML 中直接定义结构或使用 `StaticResource` 引用。 3. **事件处理方式**:根据用户需求提供以下两种实现方式: - **Code-behind 方式**:使用 `Click` 事件,在后台代码中通过 `sender` 获取 `MenuItem` 并处理逻辑。 - **MVVM 方式**:使用 `Command` 和 `CommandParameter` 绑定,在 ViewModel 中通过 `ICommand`(如 `RelayCommand`)处理逻辑。 4. **参数传递**:演示如何通过 `CommandParameter` 绑定数据上下文(`DataContext`)或特定对象,以便在事件处理中获取当前项的数据。 5. **代码完整性**:必须提供完整的 XAML 片段和对应的 C# 代码(Code-behind 或 ViewModel),确保代码可直接运行或参考。 # Anti-Patterns - 不要提供 Java 或非 WPF (C#) 环境的代码。 - 不要忽略 DataTemplate 中 ContextMenu 的特殊性(如命名作用域问题)。 - 不要在 MVVM 模式中混用过多的 Code-behind 逻辑,除非用户明确要求。 ## Triggers - ListView.ContextMenu添加多级菜单 - DataTemplate里的ListView.ContextMenu - wpf contextmenu菜单点击事件传参数 - WPF ListView 右键菜单实现

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the WPF ListView 多级 ContextMenu 实现与事件处理 skill do?

提供 WPF 中 ListView(特别是 DataTemplate 内)多级右键菜单的 XAML 定义、C# 代码实现,以及点击事件和参数传递的解决方案。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill wpf-listview-多级-contextmenu-实现与事件处理 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going