Gu.Wpf.Adorners icon indicating copy to clipboard operation
Gu.Wpf.Adorners copied to clipboard

Issue when using Overlay inside a Zoombox

Open sa-he opened this issue 3 years ago • 2 comments

Having the following minimal code sample in a plain WPF window.

    xmlns:adorn="http://gu.se/Adorners"
    xmlns:geo="http://gu.se/Geometry"
   ...
   <geo:Zoombox>
        <Rectangle
            Width="50"
            Height="50"
            Fill="Red">
            <adorn:Overlay.Content>
                <Border BorderBrush="Green" BorderThickness="10" />
            </adorn:Overlay.Content>
        </Rectangle>
    </geo:Zoombox>
  1. When zooming (mouse wheel) or dragging, the size and position of the Overlay (green border) stays the same. It refreshes e.g. when changing the position of the whole window. How can I force the Overlay to refresh as soon as the Zoombox has changed it's zoom or position?
  2. The Zoombox's features do not work if the mouse is above the Overlay (green border). Setting the border IsHitTestVisible="False" solves that problem, but in some scenarios I cannot do that (for I need to handle some mouse events). Is there a way to have IsHitTestVisible="True" and still forward the UI-events to the Zoombox so that I can do it's job?

sa-he avatar Oct 19 '21 14:10 sa-he

  1. seems to have it's source in the Zoobmox rather than Overlay. Calling InvalidateVisual seems to fix the problem.
        public static readonly DependencyProperty ContentMatrixProperty = DependencyProperty.Register(
            nameof(ContentMatrix),
            typeof(Matrix),
            typeof(Zoombox),
            new PropertyMetadata(
                default(Matrix),
                (d, e) =>
                {
                    var zb = (Zoombox)d;
                    ((MatrixTransform)zb.InternalVisual.Transform).SetCurrentValue(MatrixTransform.MatrixProperty, (Matrix)e.NewValue);
                    zb.InvalidateVisual();
                }));

sa-he avatar Nov 15 '21 09:11 sa-he

Tricky case, thanks for reporting

JohanLarsson avatar Nov 21 '21 20:11 JohanLarsson