

As some of you have noticed I have started building a real WPF application. (More than a hundred visitors a day! I must be filling some serious gap in the internet).
In this post I’ll explain some, if I might add, very neat design options I have chosen that have been made possible by WPF. So before you read on, if you haven’t already, read this to understand the nature of the application and look at some screenshots.
The key to the design I made is (two-way) Databinding. Imagine an object containing the data for the model being drawn. This object is invisible, it just contains the data. WPF allows me to bind other objects to this data container and this way share the data. So there is not a single copy being made of the data; it is just displayed in a different way. When you take a look at the screenshots you will see a single sturdy knight (in dark armor) displayed in four view. Three views use a orthographic (parallel) camera and the forth is a perspective camera. Same data just shown differently.
Next to the huge advantage of not copying the data around there is another significant benefit from this central data object: when you manipulate the object via one of the views you will see the changed immediately reflected in the other views.
Let’s take a look at another part of the application. Each view defines a camera. One of my wishes was to save the state of each view in the file that would contain the model. What I did was create an object that would contain all information of the camera that should be stored (position, direction, orientation, zoomlevel) and bound these fields to the actual camera of a view. This way, whenever I manipulate a camera the object is adjusted accordingly and when I load a file containing data for the object the camera adjusts itself instantly.
Databinding in WPF rules!
To be continued…
2 comments
This is interesting: i tougth that a 3D model could be associated only to one parent viewport. How have you been able to create multiple viewport that contain the same model?
simone
My model contains several collections (points, index arrays, texturecoordinates, normals) each viewport contains an empty model which corresponding properties bind to these.
ernow