我有一个应用程序,它从后面的代码以编程方式构建列表框。 我想使列表框中包含的元素可拖动。
我知道这可以通过使用以下xaml代码使用ListBoxDragDropTarget在xaml中实现:
<toolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True"> <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </toolkit:ListBoxDragDropTarget>但是我需要从后面的代码而不是通过xaml实现这一点。 有没有办法从后面的代码设置拖放目标?
我似乎无法找到一个允许设置dragDropTarget的属性。 就像是:
Dim target As New ListBoxDragDropTarget target.children.add(listbox) / target.items不确定是否可能。
提前致谢!
I have an app which builds up list boxes programmatically from the code behind. I would like to make the elements contained in the list boxes draggable.
I know this can be achieved in the xaml by the use of a ListBoxDragDropTarget by using the following xaml code :
<toolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True"> <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </toolkit:ListBoxDragDropTarget>However i need to achieve this from the code behind rather than through xaml. Is there a way of setting the drag drop target from the code behind?
I cant seem to find a property which will allow the dragDropTarget to be set. Something like:
Dim target As New ListBoxDragDropTarget target.children.add(listbox) / target.itemsNot sure if it's possible.
Thanks in advance!
最满意答案
最后将问题排序。
我最终将ListBoxDragDropTarget.content设置为列表框。 (其中包含多个对象)
target.Content = listBox然后我将目标添加到wrapPanel,然后最后将wrapPanel添加到我的主网格。
wp.Children.Add(target) grdApps.Children.Add(wp)拖放功能现在正在运行!
Sorted the problem in the end.
I ended up setting the ListBoxDragDropTarget.content to the list box. (Which contained multiple objects)
target.Content = listBoxI then added the target to the wrapPanel, then finally added the wrapPanel to my main grid.
wp.Children.Add(target) grdApps.Children.Add(wp)The drag / drop functionality is now working!
更多推荐
xaml,target,code,代码,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论