在WPF中在运行时将子级添加到Treeview中 [英] Add child into treeview at run time in WPF

查看:104
本文介绍了在WPF中在运行时将子级添加到Treeview中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时将项目添加到树视图控件中?

How to add items to treeview control at runtime?

推荐答案

在WPF中有两种有效的实现方法,它们有时被称为错误的方法正确的方法.我在这里并不是很轻松,但是TreeView是WPF中使用最广泛的控件之一,因为人们经常尝试直接操作它,这既麻烦又复杂,而不是使用MVVM来填充它,这要简单得多.

WPF大师Josh Smith在MVVM
There are effectively two ways to achieve this in WPF, and they are sometimes known as the wrong way and the right way. I''m not being flippant here, but the TreeView is one of the most abused controls in WPF because people often attempt to manipulate it directly which is messy and complex, rather than populating it using MVVM, which is a lot simpler.

WPF Guru, Josh Smith, posted an excellent tutorial on working with the TreeView using MVVM here[^]. Well worth reading and trying the sample - you will learn how easy it is to use the TreeView using MVVM.


这篇关于在WPF中在运行时将子级添加到Treeview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆