In This Topic
This topic will give you a head start on creating great looking viewport for all of your WPF applications.
Creating a new WPF Project
- Launch Visual Studio
- From the File menu, select New, and then click Project
- In the New Project dialog box, click either Visual C# or Visual Basic from the Project types list
- From the Templates list, click WPF Application
- In the Name field, replace the default project name with the name of your project
Adding the control to your MainWindow
Add the control to your MainWindow by either double-clicking on the ViewportLayout toolbox icon (installed in the 'Eyeshot Ultimate 11' tab of the Visual Studio toolbox), or by clicking on the icon once then "drawing" the control onto the form using the left mouse button. Choose the layout from the Preset Manager and click Load.
Figure 1: The ViewportLayout control in design-time mode.
Naming the ViewportLayout control
In the MainWindow XAML editor, add the "viewportLayout1" name to the ViewportLayout control.
Figure 2: Adding a name to the WPF control.
Required using/Imports statements
Add the following using/Imports statements at the beginning of the MainWindow.xaml.cs file.
Customizing the Viewport
Change the coordinate system icon Z arrow color setting the Lighting property as false and changing the ArrowColorZ property.
Figure 3: Customizing coordinate system icon from XAML.
Drawing a box
Add the following OnContentRendered() override, then build and start your application.
You should now see something like this:
Figure 3: Your first 3D drawing with Eyeshot.
Navigation quick commands:
- Middle mouse button combined with Ctrl or Shift keys to Zoom/Pan/Rotate
- Mouse wheel to Zoom
- Ctrl+F to fit the model in the viewport
Now it's your turn
Try adding add more entities like lines, circles, etc. You'll find them in the devDept.Eyeshot.Entities namespace.
Under some circumstances you may prefer to handle InitializeScene event. This prevents a redundant viewport refresh at startup and doesn't need the closing ViewportLayout.Invalidate() call.
See Also