O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using routed commands

WPF provides two (similar) implementations for the ICommand interface. Commands are invoked (by default) by command sources, implementing the ICommandSource interface. These two interfaces comprise the basic abstraction WPF recognizes as far as commands are concerned. In this recipe, we'll examine these interfaces, their out-of-the-box implementations, and how they are typically used.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a simple image viewer that provides its functionality via WPF routed commands:

  1. Create a new WPF application named CH07.RoutedCommands.
  2. Open MainWindow.xaml. Add the following to the existing Grid:
    <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required