c# - 标签目标扩展器

标签 c# wpf

我有一个包含以下内容的标签:Fol_Der(带有 d 下划线的文件夹,表示 Alt 快捷方式)。

它的目标元素是 Expander。

我的目标是,当用户按 Alt + D 时,扩展器将展开。

但是,按下它时我得到的只是虚线轮廓:

Dashed expander

如何正确定位它以使其扩展?

最佳答案

定义命令

public static RoutedUICommand ExpandFolderCommand{ get; private set; }

 ExpandFolderCommand= new RoutedUICommand("ExpandFolderCommand", "ExpandFolderCommand", typeof(Commands),       new InputGestureCollection { 
                    new KeyGesture(Key.D, ModifierKeys.Alt, "Alt+D") });

然后在窗口/用户控件中定义命令绑定(bind)

 <UserControl.CommandBindings>
          <CommandBinding Command="{x:Static ExpandFolderCommand}"
                          Executed="ExpandFolderCommand_Executed" 
                          CanExecute="ExpandFolderCommand_CanExecute"/>
 </UserControl.CommandBindings>

ExpandFolderCommand_Executed 应该展开您的扩展器

进一步阅读Commanding Overview

关于c# - 标签目标扩展器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15052160/

相关文章:

C# WPF Xaml : Globally set all text in a view to one color, 和所有背景到另一个

c# - 数据库优先和 Entity Framework 动态连接字符串

c# - 自托管 OWIN 和 urlacl

c# - 序列化匿名类型

c# - 如何在Caliburn.Micro ViewModel中处理WPF MenuItem命令?

c# - 样式化扩展工具包 BusyIndi​​cator

c# - 如何根据 GridView 列的路径打开文件位置?并且在我想创建一个 'hyper link' 的路径中

c# - 表单提交上 HiddenFor 的替代方案?

具有实心边框的 C# winforms 按钮,如 3d

c# - 如何触发当前类(class)无法触及的事件?