使用滑块控件在 Silverlight 3 中轻松缩放图像

发布于 2024-09-05 22:06:31 字数 145 浏览 3 评论 0原文

简单的问题,

SilverLight 3 应用程序(无工具包)。 我想使用图像和滑块。 图像在加载时显示为适合屏幕,然后滑块必须在其值发生变化时放大和缩小图像。我不想使用其他任何东西,比如 deepzoom。这怎么能做到呢?

紧急,提前致谢,

Simple question,

SilverLight 3 application (no toolkit).
I want to use an image and a slider.
The image is displayed fit to screen on load, and then the slider has to zoom-in and out the image when its value changes. I don't want to use anything else, like deepzoom. How can this be done?

Urgent, Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左耳近心 2024-09-12 22:06:31

下面的 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>

在 slidervaluechangedevent 上:

    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`;

希望它有帮助:)....

The xaml code below :

<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>

And on the slidervaluechangedevent :

    this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue;
    this.layout.ApplyLayoutTransform();

LayoutTransformer is ther in toolkit, add its reference:

System.Windows.Controls.Layout.Toolkit

Without having a toolkit, u can do it but it doesn't work properly(it will never update the scrollviewer)...try it the below one :

<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>

And on the slidervaluechangedevent :

    `this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue`;

Hope it helps :)....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文