I am writing WPF code featuring Adorners. I am using Josh Smith UIElementAdorner.cs (found in a project on the Infragistic Blog ). I love the ad text. I need to carefully place my dealer so that he does not pinch the screen.
What's the best way to find out if I'm going to clip?
I use the following code to create and host my advertiser. I have a strange feeling that, based on whether I will clip on AdornerLayer , is not the best option.
var infoBubble = new InfoBubble {InformationText = @"I like cheese."};
var adornedElementRect = new Rect(Target.DesiredSize);
var layer = AdornerLayer.GetAdornerLayer(Target);
var adorner = new UiElementAdorner<Control>(Target) { Child = infoBubble };
adorner.Measure(new Size(layer.ActualWidth, layer.ActualHeight));
var adornerRect = new Rect(adorner.DesiredSize);
var top = -1*(adornerRect.Height);
var left = adornedElementRect.Width/2;
var upperLeftPoint = Target.TranslatePoint(new Point(left, top), layer);
var lowerRightPoint = Target.TranslatePoint(new Point(left + adornerRect.Width,
top + adornerRect.Height), layer);
if (upperLeftPoint.Y < 0) top -= upperLeftPoint.Y;
if (lowerRightPoint.X > layer.ActualWidth)
left -= (lowerRightPoint.X - layer.ActualWidth);
, TargetedTriggerAction, , , ( Blend), . , .