Exercise: Bind the Rotation Angle of Rectangles to a Textbox

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> WPF - Visual C#  (20 exercises)
Topic ==> Basic binding  (2 exercises)
Level ==> Relatively easy
Course ==> WPF using Visual C#
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Open the window in the above folder, and set it to be the default one for your application.  When you run your application, you should see some rectangles:

Various rectangles

At this stage it doesn't matter what you type in as an angle - it won't have any effect on the rectangles.


Now change the angle of the transforms so that instead of being hard-coded to 20, it takes the value typed into the textbox (you need to set the ElementName and Path attributes of the RotateTransforms' Angle properties!).

You'll need to give the textbox a Name property first.

As always, it's the render transform which will look strangest (the colours have been changed to show this):

Rectangles with no rotation Rectangles with 60 degree rotation
0 degrees 60 degrees

Close down this window! 

This page has 0 threads Add post