문제

I'm using Microsoft.Expression.Controls.Callout to paint a callout object on a Canvas. Most of the time it looks fine, as below:
Normal

However, when it is resized, the anchor point (and part of the drop shadow) is somehow cut off:

Cutoff

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

다른 팁

I solved the same problem by overriding: MeasureOverride(Size constraint)

protected override Size MeasureOverride(Size constraint)
{
    return constraint;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top