Welcome!

Miguel Katrib

Subscribe to Miguel Katrib: eMailAlertsEmail Alerts
Get Miguel Katrib via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Article

Dare to Use the Current Capabilities of Windows Presentation Foundation

And get 3D layout effects

The Windows Presentation Foundation community is growing because WPF facilitates the development of better graphical user interfaces and graphical applications. But WPF's tri-dimensional resources are not developed compared to DirectX's capabilities and existing hardware potential. This article will explain how to develop panels to make it easier to lay out tri-dimensional figures in a Viewport3D.

The Bi-dimensional Hierarchy
In WPF the bi-dimensional world is hierarchically organized as shown in Figure 1. The type Visual is the base class of any element that can be shown in WPF, while its descendant UIElement defines the elements that can interact with the users through keyboard, mouse, and stylus events. FrameworkElement is the unique implementation of UIElement right now, so FrameworkElement is the actual base class for UI elements in WPF.

Shape is the representation of bi-dimensional geometric figures that can be used to build the appearance of windows and it is also useful as the main kind of artistic components in control templates.

Decorators (descendants from type Decorator) can decorate a contained element.

Controls are the main actors of the user interface. They can be seen through its control template that can be defined using any WPF element.

Panels are not properly "visible" objects because their function is to lay out a collection of elements in the bi-dimensional world.

Is the Tri-Dimensional World Organized As Well As the Bi-Dimensional?
Not yet! Unfortunately, there is no equivalent 3D hierarchy of types as in Figure 1. For example, there aren't basic 3D figures like spheres, cubes, planes, or cones. Nor is there a kind of Control3D or Panel3D hierarchy. The good news is that Microsoft's WPF team announced some tips about the future of this hierarchy in upcoming versions; the type UIElement3D in version 3.5 of the .NET Framework is so similar to UIElement that the coincidence is not by chance, and they are promising more for the next version. But while we wait for these things, this article will help you create a custom Panel3D so you can create some 3D distribution of the objects in your applications such as the familiar Windows Vista Switching (see Figure 2).

Building a Panel3D
Figure 3 shows the 3D hierarchy in the .NET Framework 3.5. The type Visual3D is the base class of all tri-dimensional elements that can be shown in a Viewport3D. ModelVisual3D is a container grouping of the elements of the 3D space. UIElement3D is the base class of those tri-dimensional elements having user interaction. Viewport2DVisual3D is the type for helping to set bi-dimensional elements as materials of the tri-dimensional figures, but keeping the interaction with the bi-dimensional elements. ContainerUIElement3D and ModelUIElement3D are two interesting classes derived from UIElement3D. The former is a group of UIElement3D objects, and the latter provides event-driven functionality to native types derived from Model3D.

Because ContainerUIElement3D and ModelVisual3D are both container elements, they could be used as a base class for our Panel3D. To obtain a 3D hierarchy similar to the bi-dimensional one shown in Figure 1, the suitable base type should be ContainerUIElement3D, but unfortunately that class is sealed, so we will use ModelVisual3D as the base class of the "panel" class.

More Stories By Miguel Katrib

Miguel Katrib is a PhD and a professor in the Computer Science Department at the University of Havana. He is also the head of the WEBOO group dedicated to Web and object-oriented technologies. Miguel is also a scientific advisor in .NET for the software enterprise CARE Technologies, Denia, Spain.

More Stories By Mario del Valle

Mario del Valle is working toward his MS at the Computer Science Department at the University of Havana, and is a software developer at the WEBOO group dedicated to Web and object-oriented technologies.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.