Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Presentation Layer vs. Core Layer Applications



The Microsoft Surface SDK includes two sets of APIs: the Presentation layer and the Core layer. Each layer is targeted toward a different development model. The most important planning decision for your Surface application is whether to use the Presentation layer or the Core layer. Both layers can make use of the unique features of the Surface environment. You should choose the layer that is best suited to the requirements of your application.

The Core Layer

The Core layer exposes Surface-specific touch data and events so you can create Surface-enabled applications with any user interface (UI) framework that is based on HWND. The samples, project templates, and other components in the Surface SDK use the Core layer by using the Microsoft XNA 4.0 development platform, but you could also use other UI frameworks such as Microsoft Managed DirectX or Microsoft Windows Forms. You can use Microsoft XNA to create dynamic and sophisticated graphics; XNA supports complex two-dimensional (2-D) and three-dimensional (3-D) rendering.

Because the Core layer does not depend on a specific UI framework, the Core layer is flexible in how you can use it. But the Core layer also does not have the pre-built controls that you can use with the Presentation layer of the Surface SDK.

When to Use the Core Layer

Use the Core layer when your Surface application requires high-end graphics, such as complex 3-D animation or rich rendering with custom pixel shaders.

Use the Core layer if your application requires access to raw image data from the vision system.

For more information, see Developing Core Layer Surface Applications.

The Presentation Layer

The Presentation layer uses Microsoft Windows Presentation Foundation (WPF) 4.0, which is the standard choice for developing touch-enabled applications because it facilitates many development needs, including custom controls, which are touch-enabled by default, and many standard user interface (UI) elements, such as buttons, labels, and scroll bars. With WPF, you can use custom graphics to create content-rich applications. By building applications with the Presentation layer, you can focus on your application's needs while WPF and pre-built controls handle the common tasks.

The Presentation layer includes a suite of Surface-enabled versions of standard WPF controls. It also supports the use of XAML files for rapid UI development. To minimize how much you have to learn if you have WPF experience, the Presentation layer exposes routed events and attached properties in a way that is consistent with the WPF model for providing you with information about mouse and stylus input. The Presentation layer also enables a multi-capture system so that one or more touch points on a device made for Surface can capture each UI element.

By using the Presentation layer, you can create assets for the UI of an application in XAML files by using Microsoft Expression Blend 4 design software, and bring those pieces into a Surface project. You can also open an existing Surface project (created using one of the Microsoft Visual Studio 2010 project templates for Surface) in Expression Blend 4 to work on the UI design.

When to Use the Presentation Layer

Use the Presentation layer when your Surface application does not require high-end graphics, such as complex 3-D animation.

Use the Presentation layer when you want to take advantage of built-in Microsoft Surface controls that you can use to rapidly create and style a sophisticated application.

For more information, see Developing Presentation Layer Surface Applications.

Using Core APIs in Presentation Applications

There are some situations in which you might want to mix the Presentation and Core APIs. For example, in a Presentation layer Surface application, you could use the Core layer APIs to obtain a raw image. For an example, see Capturing Raw Images When Using WPF.

Mixing WPF and XNA

It is not recommended, but it is possible to mix WPF and XNA in a single application. The following suggested solutions are not specific to Surface development, and you can find more information about them in existing XNA and WPF resources.

WPF and XACT

You could use an XACT project in a WPF application to integrate the rich sound features of XNA in your application.

TipTip
XACT projects must be built using XACT 3 in order to work with Surface 2.0 applications.

The Grand Piano SDK sample incorporates a XACT project in a WPF application to produce simultaneous, sustained, and overlapping sounds. In the sample, the audio engine's Update method is called periodically in a Tick event handler for a repeating DispatcherTimer that ticks every 50 milliseconds. (In an XNA application, updates to the audio engine would typically occur in the game's Update method.)

WPF and XNA

To display both XNA and WPF content, you could create two windows in your application: a transparent WPF window with opaque controls, layered on top of an XNA window. Alternatively, you could host an HWND (embedded window) inside of a WPF application that would host XNA content. For more information, see WPF and Win32 Interoperation.

WPF and DirectX

To call DirectX APIs from a WPF project, you can use a D3DImage control. For more information, see WPF and Direct3D9 Interoperation.

TipTip
D3DImage supports only Direct3D 9 and Direct3D 9Ex. To use Direct3D 10, create a Direct3D 10 device, and create or open a texture as a shared resource. The texture format must be compatible with WPF 4.0, Direct3D 9Ex and Direct3D 10. Next, create a Direct3D 9Ex device and open the shared texture using the pSharedHandle parameter of the IDirect3DDevice9::CreateTexture method. This keeps the processing on the graphics card and prevents software fallback.

See Also

Did you find this information useful? Please send us your suggestions and comments.

© Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.