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.

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


It’s great!

Nessun commento:

Posta un commento