none
How to hide UIElement Adorner is bound to

    Question

  • Hi,

    I need to drag and drop some objects in WPF application and want to provide user feedback while dragging using adorners. SimpleCircleAdorner example does exactly what I need except for one small thing (http://msdn.microsoft.com/en-us/library/ms771627(v=vs.85).aspx).

    While the object is dragged, you can see it moving as you drag (good), but the original object is also visible so there are 2 copies visible on screen (not good). It is much more natural from the UI point of view for the original object to be invisible as it happens in the real world when you drag objects arund.

    Anyway, I tried to hide the original UIElement, but that makes adorner disappear too. Obviously adorner inherits everything from the UIElement it is bound to, but in this case I would like to break that link for visible property.

    Does anyone know how to do this?

    In short I want to hide the UIElement which adorener is bound to without hiding the adorner.

    Regards

    Dejan


    • Edited by dejan1 Friday, August 31, 2012 12:03 PM
    Friday, August 31, 2012 11:59 AM

Answers

  • Hi dajan1,

    I spent a lot of time on your issue, I think there is no solution, we could not break the link between "_originalElement" and "_overlayElement", no matter we set any properites on "_originalElement", this effect will be applied on adorner element.

    I think the only workaround is "real drag", I mean that we could drag the real object, and this object will move away from original position, before drag, you could add circle on the object,

    Before drag:

    Canvas.Remove(originalElement);

    Canvas.Add(new Object()); //this object is the effect you want when dragging.

    drag finish:

    Canvas.Remove(new object);

    Canvas.Add(originalElement);

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by dejan1 Wednesday, September 05, 2012 8:44 AM
    Monday, September 03, 2012 8:01 AM

All replies

  • Hi dajan1,

    I spent a lot of time on your issue, I think there is no solution, we could not break the link between "_originalElement" and "_overlayElement", no matter we set any properites on "_originalElement", this effect will be applied on adorner element.

    I think the only workaround is "real drag", I mean that we could drag the real object, and this object will move away from original position, before drag, you could add circle on the object,

    Before drag:

    Canvas.Remove(originalElement);

    Canvas.Add(new Object()); //this object is the effect you want when dragging.

    drag finish:

    Canvas.Remove(new object);

    Canvas.Add(originalElement);

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by dejan1 Wednesday, September 05, 2012 8:44 AM
    Monday, September 03, 2012 8:01 AM
  • Hi dejan1,

    I have developed a generic solution for WPF based on behaviors and popup instead of adorners:
    http://charly-studio.com/blog/generic-wpf-dragdrop/

    if you plug the DragSourceBehavior on any UIElement, this make it draggable with 2 possible modes: duplication / move.

    You just need to develop a DropTargetBehavior to implemented the way the dropped element is managed by receiver.

    You can also implement some validation rules (CanDrop...)

    Hope this will help a bit...

    Regards,


    Charles HETIER http://www.charly-studio.com

    Monday, September 03, 2012 9:23 AM
  • Hi,

    Thanks for your effort Sheldon _Xiao.

    Post below seems to describe something similar to what I need. To them it is a problem, but anyway, it seems that it is possible at least under certain conditions. Solution talks about bidning the visibility property. Is it possible to interfere with this process? Perhaps change the convert function to return the opposite of what is expected (e.g. return hidden for visible and vice versa)?

    http://social.msdn.microsoft.com/forums/en-US/wpf/thread/3d8baad5-39f7-4d57-b576-6955b4be1420/

    Dejan


    • Edited by dejan1 Tuesday, September 04, 2012 3:25 AM
    Tuesday, September 04, 2012 12:21 AM
  • Thanks for the suggestion HETIER Charles

    Problem is that my solution is nearly complete and this would mean a lot of re-work.

    I currently use a workaround of making the object being dragged (and the adorner) semi-transparent. It's not ideal, but at least it gives user some visual feedback about what is going on.

    Regards

    Dejan


    Dejan


    • Edited by dejan1 Tuesday, September 04, 2012 3:25 AM
    Tuesday, September 04, 2012 12:23 AM
  • Hi dejan1,

    I do not think the thread you shared could resolve your issue, they are two different questions, that op wants control the Visibility of Adorner, however, in your scenario, you want to control the element and element in adorner, no matter if your original element is visible, your adorner will visible, but the element in adorner will disappear.

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 04, 2012 3:25 AM