How to ...

How to create a Workspace zoom?





To create a workspace zoom effect in WPF I used LayoutTransform on the Grid. On the LayoutTransform I used ScaleTransform that has its ScaleX and ScaleY properties binded to the Slider's Value. Simple as that smily

The xaml:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title
="Workspace Zoom">
  
<Grid x:Name="mainWindowGrid">

    
<!-- Place to put Controls that are BEHIND scalable content -->
    
    
<Grid x:Name="mainGuiGrid">
      
      
<!-- Place to put SCALABLE Controls - affected by Workspace zoom -->
      
      
<Grid.LayoutTransform>
        
<ScaleTransform x:Name="uiZoomTransform"
                        ScaleX
="{Binding ElementName=uiZoomSlider, Path=Value}" 
                        ScaleY
="{Binding ElementName=uiZoomSlider, Path=Value}"/>
      </
Grid.LayoutTransform>
    
</Grid>

    
<StackPanel Orientation="Horizontal" 
                VerticalAlignment
="Top" HorizontalAlignment="Right" >
      
<Label Height="23">Workspace zoom:</Label>
      
<Slider Name="uiZoomSlider" Orientation="Horizontal" Width="80"
              Minimum
="0.25" Maximum="5" Value="1" />
    </
StackPanel>

    
<!-- Place to put Controls that are IN FRONT of scalable content -->

  
</Grid>
</Page>

>  TRY SAMPLE ZOOM XAML

DOWNLOAD sample WorkspaceZoom.xaml (2 KB) [2 Nov 2006]
Code colorized by: CarlosAg.CodeColorizer
Copyright © 2007 by Andrej Benedik. All Rights Reserved.