SandDock for WPF User Guide

Window Switching

Back to Table of Contents

Default Switcher Types

We decided to make the concept of window switching a first-class entity in the SandDock class library, because many different implementations of this simple operation already exist and more will be created in the future thanks to the potential of WPF for smooth and pleasing animated transitions. We use the term window switching to mean an operation, usually triggered by a keyboard combination like Ctrl-Tab, where the user switches to an alternative window than the one they were working in.

The WindowSwitcherType property of your DockSite determines which of the built-in switchers is active. The following values are valid:

WhidbeyA Visual Studio 2005 style adorner appears, presenting your tool windows and documents in parallel lists for selection.
Tab3DA Windows Vista style 3D interface appears, moving representations of your windows around in 3D space for selection.
QuickTabsAn Internet Explorer style tabular list of your windows in reduced preview form appears.

Building a Custom Switcher

You can create your own user interface for switching between windows. To do this, you need to inherit from the WindowSwitcher class and assign a reference to the type of your derived class to the CustomWindowSwitcherType property on your DockSite. In your derived class the OnStarted and OnStopped virtual methods are called when your user interface needs to be displayed and subsequently removed. The base class exposes three arrays, AllWindows, ToolWindows and DocumentWindows for your derived class to use, all of which are sorted with the most recently used window first.

The NextWindow and PreviousWindow methods are called when the user Ctrl-Tabs and Shift-Ctrl-Tabs through your list, respectively. Your implementation of these methods needs to perform logic specific to your interface and set the PreviewingWindow property on the base class to indicate that a specific window is being previewed. If there is a window being previewed when the operation is stopped, it is activated.

For more advanced switchers where a graphical preview of windows is required, we offer the PreviewWindowSwitcher class to derive from. This replaces the OnStarted and OnStopped methods with OnStartedPreviewing and OnStoppedPreviewing methods for you to implement. The key property on this class is WindowPreviews, which exposes an array of WindowPreview class instances that represent the eligible windows in your layout. We created the WindowPreview class to abstract away the specific optimizations we do to get efficient graphical previews of SandDock windows. All your implementation needs to care about is the VisualBrush property of each window preview, which can be used with the WindowSize property to show a preview - whether in 2D or 3D space.