سؤال

I have Behavior class for list box item.

public class DragAndDropBehavior : Behavior<AllocationItem>
{
    protected override void OnAttached()
    {
        base.OnAttached();
        AssociatedObject.StartDrag += OnStartDrag;
    }

    protected override void OnDetaching()
    {
        base.OnDetaching();
        Cleanup(true);
    }
    // Some drag logic.
}

In this behavior I move item preview on chart and scroll this chart if need. When I do scrolling of this chart, in one moment my dragging element disappears from view - it is out of view range. And in this moment all handlers do not call. Any suggestions why?

I have some updates. When my element hides fires OnDetaching() method and all handlers of dragging remove. So, question chanches - How to ignore OnDetaching() on element hiding?

هل كانت مفيدة؟

المحلول

I solved this problem. My items placed on custom panel(chart) and this custom panel has overrided MeasureOverride(Size size) method, in whitch all items updates and unvisible items dispose from view => OnDetaching() method of behavior fires. I solved it by adding flag of dragging into my custom panel and by this flag value I solve if I need to dispose unvisible elements.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top