项目未在 Viewbox、Silverlight 的调整大小上绘制

发布于 2024-10-14 22:20:07 字数 1660 浏览 3 评论 0原文

我目前正在 Silverlight 中设计一个布局应用程序,并且在 Viewbox 内部有一个 Canvas。我向画布添加形状并且它们正确显示,当我调整视图框大小以放大 2 倍高度和宽度时,所有内容仍然正确绘制。

当我尝试以 4 或更大倍数或 0.5(缩小)缩放时,问题就出现了。

更新:水平线仍然存在,只是没有绘制。其他形状和消失的形状之间的相互作用仍然存在

当我这样做时,任何水平线都不会重绘,但任何其他形状、其他形状的垂直线仍然可以很好地重绘。这些对象仍然是画布的子对象,并且它们的可见性全部设置为可见。

怎么了?

更新
非常简单的 XAML:

<ScrollViewer x:Name="scrollViewer" 
              Padding="0"
              ScrollViewer.VerticalScrollBarVisibility="Auto"
              ScrollViewer.HorizontalScrollBarVisibility="Auto"
              IsTabStop="False"
              Background="Beige">
    <Viewbox x:Name="viewBox" Stretch="UniformToFill">
        <Canvas x:Name="designCanvas"  
                Background="{Binding ElementName=mainControl, Path=Background, Mode=TwoWay}">
        </Canvas>
    </Viewbox>
</ScrollViewer>

这是我添加形状的方法:

Rectangle horGuide = new Rectangle()
            {
                Tag = "horGuide",
                Fill = new SolidColorBrush(Colors.Cyan),
                Height = 0.5,
                Width = designCanvas.canvActualWidth*16,
            };

            int h = designCanvas.horOffset; 
            int v = designCanvas.vertOffset;
            double d = e.GetPosition(sideRule).Y;

            designCanvas.Children.Add(horGuide);
            Canvas.SetTop(horGuide, ((d+v )/ designCanvas.zoomFactor));
            Canvas.SetLeft(horGuide, 0 - h);

放大:

       viewBox.Width *= 2;
       viewBox.Height *= 2;

I am currently designing a layout app in Silverlight and have a Canvas inside of a Viewbox. I add shapes to the canvas and they display properly, when I resize the viewbox to zoom in at 2x the height and width, everything still draws properly.

The problem comes when I try to zoom at a factor of 4 or greater or at 0.5 (zoomed out).

Update: The horizontal lines are still there, they are just not drawing. Interaction between the the other shapes and the disappearing ones is still present

When I do this, any horizontal lines do not redraw, but any other shapes, vertical lines of other, still redraw fine. The objects are still children of the canvas and their visibilities are all set to visible.

What is happening?

Update
Very Simple XAML:

<ScrollViewer x:Name="scrollViewer" 
              Padding="0"
              ScrollViewer.VerticalScrollBarVisibility="Auto"
              ScrollViewer.HorizontalScrollBarVisibility="Auto"
              IsTabStop="False"
              Background="Beige">
    <Viewbox x:Name="viewBox" Stretch="UniformToFill">
        <Canvas x:Name="designCanvas"  
                Background="{Binding ElementName=mainControl, Path=Background, Mode=TwoWay}">
        </Canvas>
    </Viewbox>
</ScrollViewer>

Here is how I add the shapes:

Rectangle horGuide = new Rectangle()
            {
                Tag = "horGuide",
                Fill = new SolidColorBrush(Colors.Cyan),
                Height = 0.5,
                Width = designCanvas.canvActualWidth*16,
            };

            int h = designCanvas.horOffset; 
            int v = designCanvas.vertOffset;
            double d = e.GetPosition(sideRule).Y;

            designCanvas.Children.Add(horGuide);
            Canvas.SetTop(horGuide, ((d+v )/ designCanvas.zoomFactor));
            Canvas.SetLeft(horGuide, 0 - h);

To Zoom in:

       viewBox.Width *= 2;
       viewBox.Height *= 2;

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

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

发布评论

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

评论(1

天涯离梦残月幽梦 2024-10-21 22:20:07

为什么不使用 ScaleTransform 类来放大和缩小。

Why not use the ScaleTransform class to zoom in and out.

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