December 2014
Intermediate to advanced
512 pages
17h 4m
English
Visual has a TransformToAncestor method that returns a GeneralTransform2DTo3D. This is useful when a Visual is hosted by a Viewport2DVisual3D. The returned object converts the hosted Visual’s 2D coordinate space into the 3D coordinate space of the Visual3D.
In Listings 8.8 and 8.9, the Point (0,0) from the Viewport2DVisual3D’s hosted Button is mapped into 3D space, and a purple cube is drawn where that Point3D lies in 3D space. As the larger cube rotates, the smaller cube follows it because the GeneralTransform2DTo3D changes as the larger cube rotates. Figure 8.52 shows the result.
LISTING 8.8 MainWindow.xaml: The Cube of Buttons and the Small Purple Cube
<Window x:Class="MainWindow"
Read now
Unlock full access