我需要为我的项目创建一个可编辑的TreeListView
。但是据我所知,WPF
没有提供任何类型的树形列表视图,而我在网上找到的那些也不是很有用。我想使用Blend
创建一些东西,然后将其应用到我的WPF
项目中。
有人有什么想法吗?
谢谢。
我需要为我的项目创建一个可编辑的TreeListView
。但是据我所知,WPF
没有提供任何类型的树形列表视图,而我在网上找到的那些也不是很有用。我想使用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);
}
}