Silverlight从后面的代码中设置ListBoxDragDropTarget子项/项(Silverlight set ListBoxDragDropTarget children/items f

编程入门 行业动态 更新时间:2024-10-23 11:28:17
Silverlight从后面的代码中设置ListBoxDragDropTarget子项/项(Silverlight set ListBoxDragDropTarget children/items from code behind)

我有一个应用程序,它从后面的代码以编程方式构建列表框。 我想使列表框中包含的元素可拖动。

我知道这可以通过使用以下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.items

Not 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 = listBox

I 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

本文发布于:2023-07-25 22:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1267210.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   ListBoxDragDropTarget   Silverlight   set   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!