0

背景信息:长话短说,我们公司目前正在使用 Telerik Silverlight 工具和 Silverlight 工具包来完成我们在计划中需要的内容。由于 Silverlight 即将消亡且 Silverlight 工具包自 2011 年以来未更新,我们正在删除对 Silverlight 工具包的所有依赖项,并尝试用 Telerik Alternative 替换这些控件,这样我们就不会同时使用这两个工具包。这样我们的客户只需要下载一个 5mb 的文件而不是 10mb 的文件。

由于没有 Telerik 替代 LayoutTransformer,我决定从源代码中提取代码并将其放入我们的项目中。从此处从工具包中提取源文件后,将它放在我的项目中,然后更新所有引用我最终遇到了一个小问题。

有问题的屏幕应该看起来像这样:好的

但更改后它最终看起来像这样:坏的


我唯一更改的是

<UserControl
   ...
   xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit">

<UserControl
   ...
   xmlns:layoutToolkit="clr-namespace:Company.MyApp.App.Controls.LayoutTransformer">

使控件引用我提取的代码而不是程序集中的代码。


似乎包含所有信息的网格没有自动调整大小,而是所有信息都被塞进了那个小区域。(即使代码都没有改变)


有谁知道是什么可能导致新的 LayoutTransformer 表现得像这样即使所有代码在技术上都是相同的?我从工具包中提取代码并将其放入我的项目中是否有问题?我试图将其仅确定为相关信息,但如果您需要更多信息,请告诉我。谢谢!

4

2 回答 2

0

Couldn't get the LayoutTransformer to work no matter what I did so I just ended up switching it to a RenderTransform. From that change I got the problem that the ScrollViewer wasn't changing the scrollbars according to the width of the StackPanel when I would zoom in/out (the reason we went with the LayoutTransform in the first place is because it would automatically do that for you). To fix this I found a workaround by wrapping the StackPanel (which is being transformed) in a Canvas. Then when the StackPanel is being transformed I set the size of the Canvas. Here's the code below for any who might need it in the future.

XAML:

                <ScrollViewer
                    x:Name="PageScrollViewer"
                    HorizontalScrollBarVisibility="Auto"
                    VerticalScrollBarVisibility="Auto"
                    Background="#404040">
                    <Canvas x:Name="DocumentPanelHolder" UseLayoutRounding="False">
                        <StackPanel x:Name="DocumentPanel" Orientation="Vertical"/>
                    </Canvas>
                </ScrollViewer>

C#: //Inside the on set zoom function.

            ScaleTransform st = new ScaleTransform();
            st.ScaleX = newZoomValue;
            st.ScaleY = newZoomValue;
            this.DocumentPanel.RenderTransform = st;
            this.DocumentPanel.UpdateLayout();
            this.DocumentPanelHolder.Height = this.DocumentPanel.ActualHeight * newZoomValue;
            this.DocumentPanelHolder.Width = this.DocumentPanel.ActualWidth * newZoomValue;
于 2014-10-28T00:50:53.313 回答
0

我的猜测是,您还需要将控件样式的 XAML复制到您的应用程序资源中。

<Style TargetType="layoutToolkit:LayoutTransformer">
    <Setter Property="Foreground" Value="#FF000000"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="layoutToolkit:LayoutTransformer">
                <Grid x:Name="TransformRoot" Background="{TemplateBinding Background}">
                    <ContentPresenter
                        x:Name="Presenter"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
于 2014-10-23T16:26:47.667 回答