如何在WPF中创建可编辑的treelistview?

时间:2013-04-16 16:32:11

标签: c# .net wpf blend

我需要为我的项目创建一个可编辑的TreeListView。 但据我所知,WPF没有提供任何类型的树列表视图,我在网上找到的那些视图信息量不大。我想使用blend创建一些内容,然后将其应用于我的WPF项目。

有人对此有任何想法吗?

感谢。

1 个答案:

答案 0 :(得分:0)

我使用了这样的东西,也许这会帮助你获得一个北方

<dxg:GridControl Name="GridName" Grid.Row="0">

<dxg:GridControl.Columns>

    <dxg:GridColumn FieldName="ID" Header="ID" 
                    AllowEditing="false" 
                    AllowMoving="False" AllowGrouping="False" AllowSorting="False"
                    >
    </dxg:GridColumn>

    <dxg:GridColumn Name="Name" FieldName="Name" Header="Name" AllowEditing="true"
                    AllowMoving="False" AllowGrouping="False" AllowSorting="False" >
    </dxg:GridColumn>

</dxg:GridControl.Columns>

<dxg:GridControl.View>
    <dxg:TreeListView Name="TreePeople" AutoWidth="True"
        KeyFieldName="Id" ParentFieldName="ParentId"
        TreeDerivationMode="Selfreference"
        MultiSelectMode="Row" EditorShowMode="MouseUpFocused" ShowingEditor="TreePeople_ShowingEditor" CellValueChanging="TreePeople_CellValueChanging" >
        <dxg:TreeListView.RowCellMenuCustomizations>
            <dxb:BarButtonItem BarItemName="btnAddRow"  />
            <dxb:BarButtonItem BarItemName="btnRemoveRow"  />
        </dxg:TreeListView.RowCellMenuCustomizations>
    </dxg:TreeListView>
</dxg:GridControl.View>

<i:Interaction.Behaviors>
    <dxg:TreeListDragDropManager AllowDrag="True" AllowDrop="True" AllowAutoExpand="True" Drop="TreeListDragDropManager_Drop" Dropped="TreeListDragDropManager_Dropped" />
</i:Interaction.Behaviors>

您需要在

之前列出一个列表
public void constructor()
{
    try
    {
        IPeople cli = ProxyFactory.GetPeopleSvc();
        List<People> list = cli.GetClassification();

        if (list.count > 0)
        {
            ObservableCollection<People> tmp = new ObservableCollection<People>(list);
            GridName.ItemsSource = tmp;
        }
    }
    catch (Exception e)
    {
        Message.Show(e);
    }
}