Elements that do not resize the viewport, Silverlight

I am currently developing a layout application in Silverlight and Canvasinternally Viewbox. I am adding shapes to the canvas and they are displayed correctly, when I resize the viewport to zoom in 2x height and width, everything is still drawn correctly.

The problem occurs when I try to zoom in 4or out or in 0.5(downsized).

Refresh . Horizontal lines still exist, they simply are not drawn. The interaction between other shapes and disappearing is still present.

When I do this, any horizontal lines are not redrawn, but any other shapes, the vertical lines of others, are still well redrawn. Objects are still children of the canvas, and their visibility becomes visible.

What's happening?


Very Simple XAML Update :

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

This is how I add 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);

Click to enlarge:

       viewBox.Width *= 2;
       viewBox.Height *= 2;
+3
source share
1 answer

Why not use the ScaleTransform class to increase and decrease.

0
source

Source: https://habr.com/ru/post/1788506/


All Articles