Windows Presentation Foundation

Hello, WPF

WPF from Scratch
Navigation Applications
Content Model
Layout
Controls
Data Binding
Dependency Properties
Resources
Styles and Control Templates
Graphics
Application Deployment
Where Are We?

Layout

Introduction
Layout Basics
DockPanel
StackPanel
Grid
Canvas
Viewbox
Text Layout
Common Layout Properties
When Content Doesn't Fit
Custom Layout
Where Are We?

Controls

Introduction
What Are Controls?
Handling Input
Built-In Controls
Where Are We?

Data Binding

Introduction
Without Data Binding
Data Binding
Binding to List Data
Data Sources
Master-Detail Binding
Where Are We?

Styles and Control Templates

Introduction
Without Styles
Inline Styles
Named Styles
Element-Typed Styles
Data Templates and Styles
Triggers
Control Templates
Where Are We?

Resources

Introduction
Creating and Using Resources
Resources and Styles
Binary Resources
Global Applications
Where Are We?

Graphics

Introduction
Graphics Fundamentals
Shapes
Brushes and Pens
Transformations
Visual-Layer Programming
Video and 3-D
Where Are We?

Animation

Animation Fundamentals
Timelines
Storyboards
Key Frame Animations
Creating Animations Procedurally
Where Are We?

Custom Controls

Introduction
Custom Control Basics
Choosing a Base Class
Custom Functionality
Templates
Default Visuals
Where Are We?

ClickOnce Deployment

A Brief History of Windows Deployment
ClickOnce: Local Install
The Pieces of ClickOnce
Publish Properties
Deploying Updates
ClickOnce: Express Applications
Choosing Local Install versus Express
Signing ClickOnce Applications
Programming for ClickOnce
Security Considerations
Where Are We?

Video and 3-D

7.6. Video and 3-D

Although it is beyond the scope of this book to talk about media and 3-D in detail, it is worth being aware of the support for these features.

Video is supported with the MediaElement type. This element can be added anywhere in the UI tree. Simply set its Source property to refer to the video stream it should play, as Example 7-49 shows.

Example 7-49. Using MediaElement
<MediaElement Source="C:\WINDOWS\system32\oobe\images\intro.wmv" Stretch="Fill" />

3-D content is supported through the Viewport3D control. As far as WPF's layout system is concerned, the Viewport3D is just a rectangular control, and it will be sized and positioned like any other control. However, you provide the control with 3-D model, lighting, and camera position information, and it will render that model. The control acts as a window onto a 3-D scene, as shown in Example 7-50.

Example 7-50. Viewport3D
<Viewport3D ClipToBounds="true">
    <Viewport3D.Camera>
        <PerspectiveCamera NearPlaneDistance="1" FarPlaneDistance="100"
                           LookAtPoint="0,0,0" Position="30, -2, 20" Up="0, 0, 1"
                           FieldOfView="45" />
    </Viewport3D.Camera>

    <Viewport3D.Models>

        <Model3DGroup>
            <DirectionalLight Color="#FFFFFFFF" Direction="10,25,-1" />
            <AmbientLight Color="#66666666" />

            <GeometryModel3D>
                <GeometryModel3D.Geometry>
                    <MeshGeometry3D
                        TriangleIndices="0 1 2  1 2 3  2 3 0  0 1 3"
                        Normals="-1,-1,0 1,-1,0 1,0,0 0,0,1"
                        Positions="-2,-2,-2  2,-2,-2  0,2,-2  0,0,1"/>

                </GeometryModel3D.Geometry>
                <GeometryModel3D.Material>
                    <MaterialGroup>
                        <DiffuseMaterial Brush="LightGreen" />
                        <SpecularMaterial Brush="White" />
                    </MaterialGroup>

                </GeometryModel3D.Material>
            </GeometryModel3D >
        </Model3DGroup>
    </Viewport3D.Models>
</Viewport3D>

This sets up a very simple 3-D model containing a single square-based pyramid. Figure 7-58 shows the result. The model also contains some light sources to make sure the model is visible. And the Viewport3D also has a camera position specified.

Figure 7-58. Viewport3D (Color Plate 2)


In practice, you would normally use some kind of 3-D design tool to create 3-D models, so you would not typically expect to be working with model markup such as that shown in Example 7-50. The Viewport3D just provides a convenient way of integrating the results into your visual tree.


©2008 FAQ - WPF Labs - Discuss - Terms of Use - Privacy Policy - About WPF
- Interview Questions - Sharepoint Articles - Interview Questions Resource Library - All about LINQ - MS Knowledgebase Articles - Electronics and Hardware discussions