English 中文(简体)
带画布和滚动视图的Silverlight缩放区域
原标题:Silverlight zoom area with canvas and scrollview

I have simple canvas with items and i need to add for scroll view as parent for my canvas. But i fased with problem that after set

canvas.RenderTransform=new ScaleTransform(){...}

Scroolbars not appears or working not correctly. Will be glad for any information.

最佳回答

渲染变换发生在UI渲染过程的后期。它最终在控件渲染上执行矩阵变换。滚动查看器将完全不注意此转换,其滚动条将基于原始画布的未转换大小。

silverlight工具箱包含一个LayoutTransformer控件。此控件将变换应用于其内容,作为布局过程的一部分,并将变换后的大小报告为所需的大小。

考虑一下:-

    <ScrollViewer Width="200" Height="200" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <toolkit:LayoutTransformer>
            <toolkit:LayoutTransformer.LayoutTransform>
                <ScaleTransform ScaleX="2" ScaleY="2" />
            </toolkit:LayoutTransformer.LayoutTransform>
            <Canvas Width="150" Height="150" Background="Aquamarine">
                <Rectangle Fill="Blue" Canvas.Top="10" Canvas.Left="10" Width="30" Height="30" />
            </Canvas>
        </toolkit:LayoutTransformer>
    </ScrollViewer>

虽然Canvas的大小(150)小于包含的滚动查看器(200),但它被缩放以使其更大(300)。LayoutTransformer报告其所需的大小为300,即画布的变换后大小。因此,ScrollViewer会显示滚动条来适应它。如果没有LayoutTransformer的好处,ScrollViewer将只能看到画布的大小为150,尽管应用了任何RenderTransform。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签