Lesters DragAndDropManager 내 응용 프로그램에서 끌어서 놓기 기능을 사용하고 있으며 실제로 구현 된 방식이 마음에 들지만 한 가지 작은 문제가있어서 그 것을 보여주고 싶습니다. 내 상태 표시 줄에서 드래그하는 동안 마우스 코드를 지정하면 DropManager의 마우스 위치를 내 xaml 코드로 어떻게 보내야합니까?WPF에서 드래그 앤 드롭을 할 때 mousepoint를 표시
xaml-code에서 바인드 할 수있는 관리자에 dependencyproperty를 추가하려고했습니다.
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>
하지만 어떻게 mousecordintation을 관리자의 dependecyproperty로 설정합니까?
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 코드에 mousecordination을 얻는 방법에 박히있다.
감사합니다.