Article From:https://www.cnblogs.com/lonelyxmas/p/9689236.html
Original text: WPF produces reflection effect through transparency mask and transformation.

 

Reflection effect

image

Code

<Canvas 
  xmlns=“http://schemas.microsoft.com/client/2007“
  xmlns:x=“http://schemas.microsoft.com/winfx/2006/xaml“>

  <!– The object to reflect. –>
  <Image Source=“gear_large.png“
    Canvas.Left=“75“ Canvas.Top=“20“>
  </Image>

  <!– The reflection. –>
  <Image Source=“gear_large.png” 
    Canvas.Left=“75“ Canvas.Top=“228”
    Opacity=“0.75”>
    <Image.RenderTransform> 
      <ScaleTransform ScaleY=“-0.75“ /> 
    </Image.RenderTransform> 
    <Image.OpacityMask>
      <LinearGradientBrush StartPoint=“0.5,0.0“ EndPoint=“0.5,1.0“> 
        <GradientStop Offset=“0.0“ Color=“#00000000“ /> 
        <GradientStop Offset=“1.0“ Color=“#FF000000“ /> 
      </LinearGradientBrush> 
    </Image.OpacityMask> 
  </Image> 

</Canvas>

 

More complex applications

image

Reference resources

Use Transforms and Opacity Masks to Create a Reflection in WPF/E

Opacity Masks Overview

Leave a Reply

Your email address will not be published. Required fields are marked *