0

我有以下树列表视图:

<dxg:TreeListControl Name="treeList" Grid.Row="7" Height="230" Margin="10,2,10,0">
    <dxg:TreeListControl.Columns>
        <dxg:TreeListColumn FieldName="Description" />
        <dxg:TreeListColumn FieldName="Package" />
        <dxg:TreeListColumn FieldName="Procedure" />
    </dxg:TreeListControl.Columns>
    <dxg:TreeListControl.View>
        <dxg:TreeListView Name="treeListView" KeyFieldName="Id" ParentFieldName="ParentId" />
    </dxg:TreeListControl.View>
    <dxmvvm:Interaction.Behaviors>
        <dxg:TreeListDragDropManager x:Name="dragDropManager" AllowDrag="True" />
    </dxmvvm:Interaction.Behaviors>
</dxg:TreeListControl>

我的问题是如何从树列表视图中删除选定的行。谢谢

4

1 回答 1

0

查看如何:手动控制拖放帮助文章,该文章演示了如何使用拖放相关事件为 TreeList 自定义拖放功能。

本文的主要思想 - 如果您的 TreeListControl 绑定到某个集合:

treeList.ItemsSource = Stuff.GetStuff(); // ObservableCollection<Employee>

您可以使用TreeListDragDropManager.Drop事件来更改此集合中的某些项目(例如删除项目):

void TreeListDragDropManager_Drop(object sender, 
    var employees = ((ObservableCollection<Employee>)treelist.ItemsSource);
    if(... some condition...){
        foreach (TreeListNode node in e.DraggedRows) {
            var employee = node.Content as Employee;
            employees.Remove(employee);
    }
}

DevExpress 代码示例数据库中的完整示例项目。

于 2016-02-12T11:06:54.790 回答