Basics of Reflection in WPF
Posted by codingsense on May 17, 2009
Reflection in WPF is a good feature to create better visual effects.
Create Visual Brush:
To create a basic reflection in Expression Blend we have to create a Visual Brush, to create one follow the steps.
- Open Expression blend
- Drop a image in the window
- Select the image and Select Tools-> Make Brush Resouce -> Make VisualBrush Resouce -> Click Ok
As you do this a Visual brush of your image will be created that you can apply for any objects.
Lets test it.
Now add a rectangle, Select it and go to properties window, in Burshes Select Fill -> Brush Resouce
You will find the visual brush that is created Select it, the rectangle will fill with the image.
Once we know the steps to create a visual brush we can proceed with the reflection
Once we have the rectangle filled with the visual brush resouce, we get a lot of options how to reflect the image.
I will show you one example to start with
Select the Rectangle
Select Properties -> Transform -> Scale
Set X as -1
You will see a reflected image horizontally, the same reflection you can attain by giving -1 in Y.
Try all the options in Transform Tab and you will come to know about a lot of techniques.
Here for first Image i have made half of the Rectangle Transparent, by modifying a bit in Brushes -> Opacity mask.
For the second I have added 3 rectangles which are reflecting in different angles by modifying scale in Transform Tab, and then making the image 3d and rotating it.
Happy Learning 🙂