"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"
) CHAPTER 10 n COMMANDS 301 Figure 10-4. A command with a binding nNote In this example, the event handler that responds to the command is still code inside the window where the command originates. The same rules of good code organization still apply to this example??”in other words, your window should delegate its work to other components where appropriate. For example, if your command involves opening a file, you may use a custom file helper class that you??™ve created to serialize and deserialize information. Similarly, if you create a command that refreshes a data display, you??™ll use it to call a method in a database component that fetches the data you need. See Figure 10-2 for a refresher. In the previous example, the command binding was generated using code. However, it??™s just as easy to wire up commands declaratively using XAML if you want to streamline your code-behind file. Here??™s the markup you need: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TestNewCommand"> Executed="NewCommand_Executed">