Image Reflection in WPF

Image Reflection in WPF.


In this article I am describing how to get Image Reflection effect in WPF. For demonstrating this, I have created a sample project in Microsoft Visual C# 2010 Express Edition.


Following is the code for getting the image reflection effect.


code.jpg


In the above code, first I have created a bitmap image resource called "bi" pointing to the embedded image "minnie.jpg".


Then I created a Canvas containing two Rectangles. The first Rectangle contains an ImageBrush object which displays the image.


The second Rectangle specifies an opacity mask using the LinearGradientBrush object. In the second Rectangle, I have created a VisualBrush bound to the first Rectangle using element binding. The ScaleTransform element is used to rotate the image upside down, giving the reflection effect.


Following is the output of the above code: 


output

outputoutput.jpg


I hope readers would find my article helpful.



Up Next
    Ebook Download
    View all
    Learn
    View all