C# 更改ListBoxDragDropTarget中DragDecorator的默认移动
我使用的是Silverlight工具箱中的ListBoxDragDropTarget,我希望在拖动项目时更改项目的移动。因此,在我的列表框面板中,它应该只能在面板内部移动,并且只允许垂直移动,而不允许水平移动 默认情况下,您可以在整个应用程序中从ListBox移动项目,我不认为它应该只能在ListBox中移动 因此,我尝试的是更改弹出控件和DragDecorator控件的RenderTransform,甚至更改模板中画布的RenderTransformC# 更改ListBoxDragDropTarget中DragDecorator的默认移动,c#,silverlight-4.0,drag-and-drop,silverlight-toolkit,C#,Silverlight 4.0,Drag And Drop,Silverlight Toolkit,我使用的是Silverlight工具箱中的ListBoxDragDropTarget,我希望在拖动项目时更改项目的移动。因此,在我的列表框面板中,它应该只能在面板内部移动,并且只允许垂直移动,而不允许水平移动 默认情况下,您可以在整个应用程序中从ListBox移动项目,我不认为它应该只能在ListBox中移动 因此,我尝试的是更改弹出控件和DragDecorator控件的RenderTransform,甚至更改模板中画布的RenderTransform public class FixedLis
public class FixedListBoxDragDropTarget : ListBoxDragDropTarget
{
public Popup DragPopupControl { get; set; }
public DragDecorator DragDecoratorControl { get; set; }
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
DragPopupControl = GetTemplateChild(DragPopupName) as Popup;
DragDecoratorControl = GetTemplateChild(DragDecoratorName) as DragDecorator;
}
}
在ListBoxItems上,项目a已附加MouseMove事件
private void TopicUsedControl_MouseMove_1(object sender, System.Windows.Input.MouseEventArgs e)
{
//Get the Control
var dragDropPanel = UIHelper.FindChild<FixedListBoxDragDropTarget>(Application.Current.RootVisual, "DragDropControl");
var transform = dragDropPanel.DragPopupControl.RenderTransform as CompositeTransform;
var transformDragdecorator = dragDropPanel.DragDecoratorControl.RenderTransform as CompositeTransform;
if (transform == null && transformDragdecorator == null)
{
transform = new CompositeTransform();
transformDragdecorator = new CompositeTransform();
dragDropPanel.DragPopupControl.RenderTransform = transform; //PopupControl of Template
dragDropPanel.DragPopupControl.Child.RenderTransform = transform; //Canvas inside the Template
dragDropPanel.DragDecoratorControl.RenderTransform = transformDragdecorator; // Dragdecorator of Template
}
transform.TranslateX = 0;
transform.TranslateY = 10;
transformDragdecorator.TranslateX = 0;
transformDragdecorator.TranslateY = 10;
}
我尝试将RenderTranform设置为固定值,控件不再移动以测试它。但是它没有发生任何事情,我可以用鼠标移动控件,上面的代码没有任何效果
如何更改或覆盖dragdecorator的默认移动行为