0

Lesters DragAndDropManagerを使用 して、アプリケーションでドラッグ アンド ドロップ機能を取得しています。その実装方法はとても気に入っていますが、小さな問題が 1 つあります。それは、ドラッグ中にステータス バーにマウスのコーディネーションを表示したいということです。 DropManager から xaml コードにマウス位置を送信しますか。

xaml コードでバインドできる依存関係プロパティをマネージャーに追加しようとしました。

    public static readonly DependencyProperty MousePointProperty =
        DependencyProperty.RegisterAttached("MousePoint", typeof(Point), typeof(DragDropBehavior),
        new FrameworkPropertyMetadata(default(Point)));
    public static void SetMousePoint(DependencyObject depObj, bool isSet)
    {
        depObj.SetValue(MousePointProperty, isSet);
    }
    public static IDragSourceAdvisor GetMousePoint(DependencyObject depObj)
    {
        return depObj.GetValue(MousePointProperty) as IDragSourceAdvisor;
    }

Xaml では、このようにバインドします。

    <StatusBar>
        <TextBlock Text="{Binding local:DragDropBehavior.MousePoint.X}"/>
    </StatusBar>

しかし、マネージャーでマウスコーディネーションを依存プロパティに設定するにはどうすればよいですか?

    private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
    {
        if (UpdateEffects(sender, e) == false) return;
        //-- Update position of the preview Adorner
        Point position = GetMousePosition(sender as UIElement);

        //-- Here I Want to do this, but that not posible because the SetMousePoint takes a dependencyObject and not my value.
        //-- SetMousePoint(position);

        _draggedUIElementAdorner.Left = position.X - _offsetPoint.X;
        _draggedUIElementAdorner.Top = position.Y - _offsetPoint.Y;

        e.Handled = true;
    }

私はここで間違っていると思いますが、DragAndDropManager にバインドして xaml コードにマウスコーディネーションを取得する方法に行き詰まっています。

ありがとう。

4

1 に答える 1