2013-02-24 112 views
2

我有一個標籤包含此內容:Fol_Der(帶有下劃線的Alt用於快捷方式的文件夾)。標籤目標擴展器

它所針對的元素是擴展器。

我的目標是當用戶按下Alt + D Expander將展開。

但是我得到的,當它被按下一個虛線輪廓:

Dashed expander

我怎樣可以針對得當所以它會擴大?

回答

2

定義一個命令

public static RoutedUICommand ExpandFolderCommand{ get; private set; } 

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

然後定義你的命令將在窗口/用戶控件

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

的ExpandFolderCommand_Executed應擴大您的擴展

進一步閱讀Commanding Overview

+0

阿結合,我懷疑目標不會en成爲解決方案。謝謝。 – MasterMastic 2013-02-24 14:29:58