lunedì 11 novembre 2013

WPF - Zoom an image with the slider control.

C# .NET Framework 4.0

In a WPF (XAML) view I want to zoom an image using a slider control and also in this occasion the binding help me to do this with a few code rows.

             <RowDefinition Height="*"></RowDefinition>
              <RowDefinition Height="30"></RowDefinition>
       <Image Grid.Row="0" Name="ImgReader" Source="Images/Exit.png" Stretch="Uniform" RenderTransformOrigin="0.5, 0.5" >
                    <ScaleTransform ScaleX="{Binding ElementName=SliderDocument, Path=Value}" ScaleY="{Binding ElementName=SliderDocument, Path=Value}"/>
       <Slider Grid.Row="1" Name="SliderDocument" VerticalAlignment="Center" Minimum="0.1" Maximum="1" />

It’s great!