【发布时间】:2010-06-14 17:54:54
【问题描述】:
简单的问题,
SilverLight 3 应用程序(无工具包)。 我想使用图像和滑块。 图像在加载时显示为适合屏幕,然后滑块必须在其值更改时放大和缩小图像。我不想使用其他任何东西,比如 deepzoom。如何做到这一点?
紧急,提前谢谢,
【问题讨论】:
标签: silverlight zooming
简单的问题,
SilverLight 3 应用程序(无工具包)。 我想使用图像和滑块。 图像在加载时显示为适合屏幕,然后滑块必须在其值更改时放大和缩小图像。我不想使用其他任何东西,比如 deepzoom。如何做到这一点?
紧急,提前谢谢,
【问题讨论】:
标签: silverlight zooming
下面的xaml代码:
<ScrollViewer x:Name="scroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<layout:LayoutTransformer x:Name="layout" Background="{x:Null}" >
<layout:LayoutTransformer.LayoutTransform>
<ScaleTransform x:Name="contentScale" ScaleX="1.0" ScaleY="1.0" />
</layout:LayoutTransformer.LayoutTransform>
<Image x:Name="img" Source="../pin.PNG" >
</Image>
</layout:LayoutTransformer>
</ScrollViewer>
在滑块值更改事件上:
this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue;
this.layout.ApplyLayoutTransform();
LayoutTransformer 在工具包中,添加它的引用:
System.Windows.Controls.Layout.Toolkit
如果没有工具包,你可以做到,但它不能正常工作(它永远不会更新滚动查看器)...试试下面的一个:
<ScrollViewer x:Name="scroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Themes:ThemeManager.StyleKey="TreeScrollViewer">
<Image x:Name="img" Source="../charge_chargeline.PNG" >
<Image.RenderTransform>
<ScaleTransform x:Name="contentScale" ScaleX="1.0" ScaleY="1.0" />
</Image.RenderTransform>
</Image>
</ScrollViewer>
在滑块值更改事件上:
`this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue`;
希望对你有帮助:)....
【讨论】: