Silverlight Treeview 相关操作:加载,保存,索引节点,节点移动,模板节点
2009-03-14 12:00:33 来源:WEB开发网其中,节点的header属性为object类型,这样我们可以根据需求,为其赋予需要的控制项。
设置定制节点
private void setTitleData(Grid grid)
{
TextBlock Phase = new TextBlock();
Phase.Text = "Phase";
Grid.SetColumn(Phase, 0);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "Task";
Grid.SetColumn(Phase, 1);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "Item";
Grid.SetColumn(Phase, 2);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "工期";
Grid.SetColumn(Phase, 3);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "开始时间";
Grid.SetColumn(Phase, 4);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "实际开始时间";
Grid.SetColumn(Phase, 5);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "完成时间";
Grid.SetColumn(Phase, 6);
grid.Children.Add(Phase);
Phase = new TextBlock();
Phase.Text = "实际完成时间";
Grid.SetColumn(Phase, 7);
grid.Children.Add(Phase);
}
private void setGridData(Grid grid, string str, int id)
{
//序号
TextBlock flag = new TextBlock();
flag.Tag = id;
Grid.SetColumn(flag, 0);
grid.Children.Add(flag);
//名称
TextBlock lbl = new TextBlock();
lbl.Text = "[" + id.ToString() + "]" + str;
//lbl.Text = str;
Grid.SetColumn(lbl, 1);
grid.Children.Add(lbl);
//工期
TextBox txt = new TextBox();
txt.IsEnabled = false;
Grid.SetColumn(txt, 2);
grid.Children.Add(txt);
//开始时间
DatePicker dp = new DatePicker();
dp.IsEnabled = false;
Grid.SetColumn(dp, 3);
grid.Children.Add(dp);
//实际开始时间
dp = new DatePicker();
Grid.SetColumn(dp, 4);
grid.Children.Add(dp);
//完成时间
dp = new DatePicker();
dp.IsEnabled = false;
Grid.SetColumn(dp, 5);
grid.Children.Add(dp);
//实际完成时间
dp = new DatePicker();
Grid.SetColumn(dp, 6);
grid.Children.Add(dp);
}
private Grid getGridTemplate()
{
Grid grid = new Grid();
RowDefinition row1 = new RowDefinition();
grid.RowDefinitions.Add(row1);
//id
ColumnDefinition col = new ColumnDefinition();
col.Width = new GridLength(1);
grid.ColumnDefinitions.Add(col);
//ITem Name
col = new ColumnDefinition();
col.Width = new GridLength(250);
grid.ColumnDefinitions.Add(col);
//工期
col = new ColumnDefinition();
col.Width = new GridLength(50);
grid.ColumnDefinitions.Add(col);
//计划开始时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//实际开始时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//完成时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//实际完成时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
return grid;
}
private Grid getTitleGridTemplate()
{
Grid grid = new Grid();
RowDefinition row1 = new RowDefinition();
grid.RowDefinitions.Add(row1);
//Phase
ColumnDefinition col = new ColumnDefinition();
col.Width = new GridLength(40);
grid.ColumnDefinitions.Add(col);
//task
col = new ColumnDefinition();
col.Width = new GridLength(50);
grid.ColumnDefinitions.Add(col);
//item
col = new ColumnDefinition();
col.Width = new GridLength(210);
grid.ColumnDefinitions.Add(col);
//工期
col = new ColumnDefinition();
col.Width = new GridLength(50);
grid.ColumnDefinitions.Add(col);
//计划开始时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//实际开始时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//计划完成时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
//实际完成时间
col = new ColumnDefinition();
col.Width = new GridLength(150);
grid.ColumnDefinitions.Add(col);
return grid;
}
Tags:Silverlight Treeview 相关
编辑录入:爽爽 [复制链接] [打 印]- ››silverlight全屏显示图片
- ››Silverlight MVVM 模式(一) 切近实战
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››Silverlight for Symbian
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››silverlight2 游戏 1 你能坚持多少秒
- ››Silverlight开发实践--PicZoomShow
- ››Silverlight自定义控件开发 - 令人懊恼的OnApplyT...
- ››Silverlight 2 RTW中ToolTipService.ToolTip不继承...
更多精彩
赞助商链接