WPF ScrollViewer Thumbnail
ScrollViewer에서 현재 보여지고 있는 부분을 표시하기 위한 내용입니다.
참조: http://www.thejoyofcode.com/WPF_ScrollViewer_Thumbnail.aspx
[이미지 1 결과 화면]
소스 코드입니다.
<Window x:Class="HowToLayoutPreview.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ScrollViewer x:Name="myScrollViewer" Height="246" HorizontalAlignment="Left" Margin="7,37,0,0" VerticalAlignment="Top" Width="255" HorizontalScrollBarVisibility="Visible"> <Grid> <Image Source="/HowToLayoutPreview;component/Images/Chrysanthemum.jpg" Height="338" Width="357"></Image> <Button Margin="137,139,174,164">아하</Button> </Grid> </ScrollViewer> <Viewbox DataContext="{Binding ElementName=myScrollViewer}" Margin="294,0,0,0"> <Grid> <Rectangle Width="{Binding Content.ActualWidth}" Height="{Binding Content.ActualHeight}"> <Rectangle.Fill> <VisualBrush Visual="{Binding Content}" /> </Rectangle.Fill> </Rectangle> <Border BorderThickness="1" BorderBrush="Black" Background="#88FFFF00" Width="{Binding ViewportWidth}" Height="{Binding ViewportHeight}" HorizontalAlignment="Left" VerticalAlignment="Top"> <Border.RenderTransform> <TranslateTransform X="{Binding HorizontalOffset}" Y="{Binding VerticalOffset}" /> </Border.RenderTransform> </Border> </Grid> </Viewbox> </Grid> </Window> |
프로젝트 파일입니다.