There is no direct support to zoom a control like in WPF.But we could work around using RenderTransform.
- Add a ScaleTransform in the RenderTransform section
- Manipulate the X & Y values of ScaleTransform through code behind.ie in a Click event
Detailed steps
- Create a new SilverlightJavascript application ( Silverlight 1.0)
- Then you can see a Canvas which looks like a Button.Add 2 more canvases for ZoomIn and ZoomOut
<Canvas Name="ZoomIn" Width="100" Height="50" Canvas.Top="370" >
<TextBlock Text="Click me to ZoomIn"/>
</Canvas>
<Canvas Name="ZoomOut" Width="100" Height="50" Canvas.Top="370" Canvas.Left="150" >
<TextBlock Text="Click me to ZoomOut"/>
</Canvas> - Add event handlers on LeftMouseDown in Scene.XAML.js file
this.ZoomIn = rootElement.children.getItem(1);
this.ZoomIn.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.mouseDownZoomIn));
this.ZoomOut = rootElement.children.getItem(2);
this.ZoomOut.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.mouseDownZoomOut)); - Write Handlers
mouseDownZoomIn:function(sender,args)
{
var transform=this.button.RenderTransform;
transform.ScaleX=transform.ScaleX+1;
transform.ScaleY=transform.ScaleY+1;
},
mouseDownZoomOut:function(sender,args)
{
var transform=this.button.RenderTransform;
if(transform.ScaleX >1){
transform.ScaleX=transform.ScaleX-1;
transform.ScaleY=transform.ScaleY-1;
}
A sample is located here
No comments:
Post a Comment