Gu.Wpf.Adorners
Gu.Wpf.Adorners copied to clipboard
Issue when using Overlay inside a Zoombox
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>
- 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?
- 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 haveIsHitTestVisible="True"
and still forward the UI-events to the Zoombox so that I can do it's job?
- 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();
}));
Tricky case, thanks for reporting