I'm using Microsoft.Expression.Controls.Callout to paint a callout object on a Canvas
. Most of the time it looks fine, as below:
However, when it is resized, the anchor point (and part of the drop shadow) is somehow cut off:
I've tried to set different properties such as SnapToDevicePixels
, UseLayoutRounding
etc. but nothing works so far.
Here's the XAML (the callout object is used as the template for a control named CalloutElement
which inherits from Control
:
<Style TargetType="{x:Type Editor:CalloutElement}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Editor:CalloutElement}">
<ed:Callout CalloutStyle="RoundedRectangle" Fill="#FFF"
StrokeThickness="2"
AnchorPoint="0.5 1.4">
<ed:Callout.Effect>
<DropShadowEffect BlurRadius="10" Opacity="0.5"/>
</ed:Callout.Effect>
<ed:Callout.Stroke>
<SolidColorBrush Color="Red" />
</ed:Callout.Stroke>
</ed:Callout>
<!-- More XAML for resize adorner -->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Note that the resize adorner seemly displays the ovals at the corners allowing the callout to be resize. The code of the adorner only change the Width
and Height
of CalloutElement
.
Any idea on why this occurs and how to fix it? Any help is greatly appreciated.
I solved this by overriding GetLayoutClip()
method. Yes, kinda hacky, but works fine so far. Love to know if there's better solution.
protected override Geometry GetLayoutClip(Size layoutSlotSize)
{
return null;
}