Reflection Effect Demo (반영 효과)



 Reflection Effect 의 주요 컨셉은 "Transformation", "Visual Brushes", "Gradients" 라고 한다.










<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ReflectionDemo.Window1"
    Title="WPF Reflection Effect" Height="420" Width="300" Background="#FF000000">
   
    <Window.OpacityMask>
        <LinearGradientBrush EndPoint="0.49,0.014" StartPoint="0.49,0.986">
            <GradientStop Color="#FF000000" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="1"/>
        </LinearGradientBrush>
    </Window.OpacityMask>
   
    <Grid
        HorizontalAlignment="Center"
        VerticalAlignment="Center" Background="White">
        <!--stackpanel to hold the video and the reflective surface-->
        <StackPanel>
            <!--name the container of the video so you can reference it
            later using DataBinding-->
            <Grid Name="mainVid" Width="240" Height="180">
                <!--use a media element to house the video-->
                <!-- <MediaElement Source="Video/WPF_applications.avi" /> -->
                <Image Source="Image/1.jpg"/>
                   
               
            </Grid>
            <Rectangle Width="240" Height="180">
                <!--fill the rectangle/reflective surface with the video using
                databinding to elements-->
                <Rectangle.Fill>
                    <VisualBrush Visual="{Binding ElementName=mainVid}" Stretch="Uniform">
                        <VisualBrush.Transform>
                            <!--the video and rectangle are on top of eachother-->
                            <TransformGroup>
                                <!--use transforms to move the rectagle to the correct location-->
                                <ScaleTransform ScaleY="-1"/>
                                <!--flip rectangle-->
                                <TranslateTransform Y="180" />
                                <!--this is the height of the original vid-->
                            </TransformGroup>
                        </VisualBrush.Transform>
                    </VisualBrush>
                </Rectangle.Fill>
                <Rectangle.OpacityMask>
                    <!--use opacity mask to give the illusion of being faded out-->
                    <LinearGradientBrush EndPoint="0.506,0.483" StartPoint="0.506,0.072">
                        <GradientStop Color="#4B000000" Offset="0"/>
                        <GradientStop Color="#18FFFFFF" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.OpacityMask>
            </Rectangle>
        </StackPanel>
    </Grid>
</Window>



※ 출처 에서는 animation 을 플레이 시켰는데, 파일을 바꾸어서 실행 시켜 보아도
   안된다...



cf ) http://sdasrath.blogspot.com/search/label/WPF





Posted by six605
,