Reader Level:
ARTICLE

Commands in WPF: Part III

Posted by Diptimaya Patra Articles | WPF March 09, 2010
In Part II of this article series we have seen the concepts of Commands and we experienced Command Binding feature. In this article we will see how Input Binding is helpful.
  • 0
  • 0
  • 7567
Download Files:
 

Introduction

In Part II of this article series we have seen the concepts of Commands and we experienced Command Binding feature. In this article we will see how Input Binding is helpful.

As we discussed in our last article InputBinding is an association between a particular input and command.

We will modify our Application such that without Button Click how we can call the Properties Command.

So our UI will contain only the TextBox control, we would get rid of the Button that we used in our previous sample.

image1.gif

image2.gif

As you see above we have only a TextBox control that doesn't have any Commands associated.

Now in Code behind retain the CommandBinding. We have to just create an InputBinding object with the proper Command and KeyGestures.

Follow the below code:


image3.gif


As you see above we have created the InputBinding object with ALT+ENTER as the KeyGesture.

Now let's run the application and see by pressing the above key combination what happens.

image4.gif

And we have the Command successfully running on KeyGesture.

Now we can have key combination of our choice and it will handle the Properties Command.



Hope this article helps, understanding InputBinding.

COMMENT USING