基本信息
源码名称:WPF TreeGrid(树形展开的表格)
源码大小:0.06M
文件格式:.zip
开发语言:C#
更新时间:2019-05-12
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
博客中会详细介绍 可以看博客http://blog.csdn.net/lhx527099095
博客中会详细介绍 可以看博客http://blog.csdn.net/lhx527099095
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace TreeGrid
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ObjForTest root = new ObjForTest("root", "root",0,"",0);
ObjForTest c1 = new ObjForTest("CEO", "Leo",45,"M",1);
ObjForTest c2 = new ObjForTest("CFO", "Tami",46,"FM",1);
ObjForTest c3 = new ObjForTest("COO", "Jack",47,"M",1);
ObjForTest cc1 = new ObjForTest("Manager", "John", 30, "M", 2);
ObjForTest cc2 = new ObjForTest("Manager", "Lee", 31, "FM", 2);
ObjForTest cc3 = new ObjForTest("Manager", "Chris", 32, "M", 2);
ObjForTest ccc1 = new ObjForTest("Worker", "Evan", 25,"FM",3);
root.Children.Add(c1);
root.Children.Add(c2);
root.Children.Add(c3);
c1.Children.Add(cc1);
c2.Children.Add(cc2);
c3.Children.Add(cc3);
cc1.Children.Add(ccc1);
this._list.ItemsSource = root.Children;
}
}
public class ObjForTest : INotifyPropertyChanged
{
public ObjForTest(string title, string name,int age,string sex,int level)
{
this._jobTitle = title;
this._sex = sex;
this._age = age;
this._name = name;
this._level = level;
}
private string _name;
private int _age;
private string _sex;
private int _level;
private string _jobTitle;
public string Sex { get { return this._sex; } set { this._sex = value; } }
public int Age { get { return this._age; } set { this._age = value; } }
public int Level
{
get
{
return this._level;
}
set
{
_level = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Level"));
}
}
public string JobTitle
{
get { return _jobTitle; }
set
{
_jobTitle = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("JobTitle"));
}
}
public string Name
{
get { return _name; }
set
{
_name = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
private ObservableCollection<ObjForTest> _children = new ObservableCollection<ObjForTest>();
public ObservableCollection<ObjForTest> Children
{
get { return _children; }
}
public event PropertyChangedEventHandler PropertyChanged;
}
}