adorner

DrawingContext adorner - possible to draw stackpanel?

那年仲夏 提交于 2019-12-06 05:54:16
问题 Using the DrawingContext class I've been able to use the DrawRectangle() method to successfully add an adorner to my adornedElement. Is it possible to construct a stackpanel, with a textbox and image inside - and assign this as the adorner? I'm using visual studio 2010 by the way - not microsoft expression. Thanks a lot, Dan 回答1: No, this is not possible out of the box as the DrawingContext is only meant to draw Visuals and no FrameworkElements. What you can do is create your own Adorner

What's the point to WPF adorners?

Deadly 提交于 2019-12-05 17:58:00
I've recently developed a drawing component for my company, featuring a Canvas on which you can draw certain shapes using click-and-drag. For each shape, I placed two adorners on its AdornerLayer: One for increased hit detection (basically a transparent rectangle that would exceed the shape's boundaries by a few pixels), and another for resizing (four Thumb controls on the corners). But, I ran into many problems when implementing some of the features of the component, all adorner related. They captured all preview events, since they were in another visual tree than the Canvas itself, that was

Adorner and Events on Adorned element

◇◆丶佛笑我妖孽 提交于 2019-12-05 08:24:48
I have a custom Line Shape that use an adorner to display an array and some text in the middle of that line. The problem is that the adorned behaves independently of the adorned element, and does not "transfer" the event to it. In the following code I am forced to manually relink the adorner elements to adorned element ( ta.MouseLeftButtonDown += Adorner_MouseLeftButtonDown; ), but unfortunately even this does not work... Could somebody advice what is wrong when calling this.OnMouseLeftButtonDown, why I don't receive the respective event? public class SegmentLine : Shape { AdornerLayer aLayer;

How to update the position of a drag adorner during WPF drag-n-drop?

China☆狼群 提交于 2019-12-05 02:29:09
问题 I'm using an adorner to show a 'ghost' of the element being dragged... var adornerLayer = AdornerLayer.GetAdornerLayer(topLevelGrid); dragAdorner = new DragAdorner(topLevelGrid, itemToDrag); adornerLayer.Add(dragAdorner); dragAdorner.UpdatePosition(e.GetPosition(topLevelGrid)); DragDrop.DoDragDrop(sourceItems, viewModel, DragDropEffects.Move); adornerLayer.Remove(dragAdorner); itemToDrag = null; ...but I can't find a nice way to update the position of the adorner during the drag. The closest

Why AdornerLayers are always the top most layers? Is there a way to change it?

▼魔方 西西 提交于 2019-12-04 13:20:17
Why is that the adorner layer is always rendered as the top most layer in an application (under AdornerDecorator - refer screenshot)? Is there a way to change the layer/level on to which the adorners can be drawn? In the following screenshot, AdornerLayer is added to AdornerDecorator and the Adorners (MyAdorners) are added to this AdornerLayer. But the AdornerLayer is retrieved like this, AdornerLayer layer1 = AdornerLayer.GetAdornerLayer(button1); layer1.Add(new MyAdorner(button1)); To answer my second question, Is there a way to change the layer/level on to which the adorners can be drawn? I

Argument not specified for parameter

点点圈 提交于 2019-12-04 05:10:58
问题 Using VB.net & WPF I've converted code available at Overlaying Controls in WPF with Adorners from C# to VB.Net Original C# Code /// <summary> /// Overlays a control with the specified content /// </summary> /// <typeparam name="TOverlay">The type of content to create the overlay from</typeparam> public class OverlayAdorner<TOverlay> : Adorner, IDisposable where TOverlay : UIElement, new() { private UIElement _adorningElement; private AdornerLayer _layer; /// <summary> /// Overlay the

WPF Adorner Clipping

独自空忆成欢 提交于 2019-12-04 04:16:43
I have an ItemsControl in a ScrollViewer . The items in the ItemsControl are expanded to a DataTemplate which basically consists of an Adorner . Now the problem is, when scrolling, the Visual Children of the Adorner are visible outside the ScrollViewer . Lets say I scroll from the Horizontal Offset 0 to 100, the Visual Children of the Adorner move to the left and are visible next to the ScrollViewer , although they should be hidden. Setting ClipToBounds on the ItemsControl or the ScrollViewer does not work. I understand, that Adorner are rendered above all elements z-order wise, but they

Why does my adorner not re-render when the element it's applied to changes?

本小妞迷上赌 提交于 2019-12-02 19:18:26
In a UI I'm building, I want to adorn a panel whenever one of the controls in the panel has the focus. So I handle the IsKeyboardFocusWithinChanged event, and add an adorner to the element when it gains the focus and remove the adorner when it loses focus. This seems to work OK. The problem I'm having is that the adorner isn't getting re-rendered if the bounds of the adorned element changes. For instance, in this simple case: <WrapPanel Orientation="Horizontal" IsKeyboardFocusChanged="Panel_IsKeyboardFocusChanged"> <Label>Caption</Label> <TextBox>Data</TextBox> </WrapPanel> the adorner

Argument not specified for parameter

跟風遠走 提交于 2019-12-02 03:11:33
Using VB.net & WPF I've converted code available at Overlaying Controls in WPF with Adorners from C# to VB.Net Original C# Code /// <summary> /// Overlays a control with the specified content /// </summary> /// <typeparam name="TOverlay">The type of content to create the overlay from</typeparam> public class OverlayAdorner<TOverlay> : Adorner, IDisposable where TOverlay : UIElement, new() { private UIElement _adorningElement; private AdornerLayer _layer; /// <summary> /// Overlay the specified element /// </summary> /// <param name="elementToAdorn">The element to overlay</param> /// <returns><

GetAdornerLayer mysteriously returning null

会有一股神秘感。 提交于 2019-12-01 03:21:20
I've been using the same bit of code for several versions of my app with no problems, but I'm now mysteriously receiving NullRerefenceException s with the following: this.Loaded += delegate { deleteBrush = new DeleteBrushAdorner( background ); AdornerLayer al = AdornerLayer.GetAdornerLayer( background ); al.Add( deleteBrush ); // null ref here?? }; background is just a Border element. My two thoughts on what could be causing it are a) switching to .NET 4.0, and b) placing instances of the above element (which is a UserControl ) in an ItemsControl . Oddly this doesn't happen all the time, and