c# - 如何在 WPF 中创建可编辑的树 ListView ?

标签 c# .net wpf blend

我需要为我的项目创建一个可编辑的 TreeListView。 但据我所知,WPF 不提供任何类型的树 ListView ,而且我在网上找到的那些也不是很有用。我想使用 blend 创建一些东西,然后将其应用于我的 WPF 项目。

有人对此有什么想法吗?

谢谢。

最佳答案

我用过类似的东西,也许这会帮助你找到北方

<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);
    }
}

关于c# - 如何在 WPF 中创建可编辑的树 ListView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16042333/

相关文章:

c# - Google Speech Api 从返回 {"result":[]} in C# 的音频文件中获取文本

.net - LINQ 到 Twitter 库的比较

c# - 在单个方法调用中改变对犀牛模拟的期望

wpf - 通过代码设置带有WPF的超链接的值

C# 和 Caliburn - RescueAttribute 和协程

c# - C# 中 Struct 的奇怪行为

c# - 如何形成我的节点和树通用类

c# - 当鼠标悬停在 ScrollViewer 上时,为什么我的 WPF 样式触发器无法仅显示水平滚动条?

wpf - 使用 StaticResource 作为 VisualTransition 的 Storyboard 时出错

c# - 如何在 XAML 中分配 Control 类型的属性 - 错误