Click here to Skip to main content
12,821,670 members (38,135 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


11 bookmarked
Posted 17 Jun 2009


, 17 Jun 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
A little while ago I wrote an article for about using 3D meshes in WPF that were hosting 2d controls, such as Grids, Lists, and User controls.

A little while ago I wrote an article for about using 3D meshes in WPF that were hosting 2d controls, such as Grids, Lists, and User controls. The article which can be found right here if you are interested.

The problem with the way that I did things in that article was that I used some fairly complicated DataTemplates within the actual 3d model XAML. These DataTemplates also had to include ContentControls that would also look at resources for their own content.

It did work, but now that .NET 3.5 has been released, there is a much better way. This better way comes in the form of a new class, called Viewport2DVisual3D. What this new class allows you to do is to create a 3d model, but it also allows you to host a 2d UIElement on a 3d Material, and the 2d UIElement is fully interactive. Its probably best if I show you and example so, ill do that now.

<Window x:Class=”Viewport2DVisual3D.Window1″
Title=”Viewport2DVisual3D” Height=”300″ Width=”300″>
<DockPanel Background=”White”>
<!– UI Mesh –>
<MeshGeometry3D x:Key=”uiMesh” TriangleIndices=”0,1,2 3,4,5″ 
    Positions=”-1,-1,2 1,-1,2 1,1,2 1,1,2 -1,1,2 -1,-1,2 “
TextureCoordinates=”0,1 1,1 1,0 1,0, 0,0 0,1″/>
<!– UI Mesh Rotation –>
<Storyboard x:Key=”uiSpin” RepeatBehavior=”Forever”>
<DoubleAnimation BeginTime=”00:00:00″ Duration=”00:00:15″ 
    Storyboard.TargetName=”uiRotate”Storyboard.TargetProperty=”Angle” From=”0″ To=”360″/>

This small example is a simple 3d mesh, with a StackPanel  filled with 4 * Button. When one of the buttons is clicked a MessageBox is shown with the content of the clickedButon as the Message.


Here is a small demo project if you would like to try this out for yourself


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.


I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 [modified] Pin
Panic2k317-Jun-09 18:28
memberPanic2k317-Jun-09 18:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 17 Jun 2009
Article Copyright 2009 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid