O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Visual3D.TransformToAncestor and Visual3D.TransformToDescendant

Visual3D contains methods for the opposite scenario of mapping from 3D space into 2D space. The GeneralTransform3DTo2D returned by Visual3D.TransformToAncestor maps from the Visual3D’s 3D coordinate space into some 2D parent’s coordinate space. This is especially useful when an app tracks a 3D point on the screen and then draws 2D content whose position must follow that 3D point.

Listings 8.10 and 8.11 use TransformToAncestor to make the TextBlocks to follow the corners of the rotating cube, as shown in Figure 8.53.

LISTING 8.10 MainWindow.xaml: The Cube and TextBlocks

<Window x:Class="MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required