Data Formats Spy Sample
This sample displays the data formats contained in any item dropped on the sample. Methods demonstrated in this sample include:
In this sample, a simple event handler monitors the PreviewDrop event on a TextBox. When a drop is detected, the data formats present in the dropped data object are displayed using the GetFormats method.
The TextBox control includes native drop handling for text-based data; this sample overrides native drop support by setting the Handled property on the PreviewDrop event to true. Note that with routed events, tunneling events (by convention, prefixed with "Preview") first propagate down through the element tree, and then bubbling events propagate back up through the element tree. Marking the tunneling PreviewDrop event as handled causes the native drop handler to skip handling the corresponding bubbling Drop event.
In addition to listing data formats in a dropped item, the sample includes the ability to filter-out non-native data formats (that is, data formats that are available through automatic data-conversion), and labels each data format as "native" or "autoconvert". The GetDataPresent method is used to differentiate between native and auto-convertible data formats.
This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of Windows Presentation Foundation (WPF) and Microsoft .NET Framework application development best practices, refer to the following as appropriate:
Accessibility - Accessibility Best Practices
Security - Windows Presentation Foundation Security
Localization - WPF Globalization and Localization Overview
Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.
Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.
To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.
To build the sample in Microsoft Visual Studio, load the sample solution or project file and then press CTRL+SHIFT+B.