MasterMastic
MasterMastic

Reputation: 21286

Label Targets Expander

I have a label with this content: Fol_Der (Folder with the d underlined for an Alt shortcut).

The element it is targeting is an Expander.

My goal is that when the user presses Alt + D the Expander will expand.

However all I get when it is pressed is a dashed outline:

Dashed expander

How can I target it properly so it would expand?

Upvotes: 2

Views: 83

Answers (1)

makc
makc

Reputation: 2579

define a command

public static RoutedUICommand ExpandFolderCommand{ get; private set; }

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

then define your command binding in your Window/UserControl

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

the ExpandFolderCommand_Executed should expand your expander

for further reading Commanding Overview

Upvotes: 2

Related Questions