【发布时间】:2011-03-31 07:55:11
【问题描述】:
我正在创建一个时间表应用程序,其中有一个员工列表以及一个要分配时间的编码列表。
我已经创建了一个 DataMatrix,并且我的网格看起来很好,除了小时的数据输入
网格看起来像
Work Coding | AL | Sick | Job1 | Job2
____________________________________________
Employee1 | | | |
Employee2 | | | |
public class DataMatrix : IEnumerable
{
public List<MatrixColumn> Columns { get; set; }
// public List<object[]> Rows { get; set; }
public List<TimesheetDetail[]> Rows { get; set; }
IEnumerator IEnumerable.GetEnumerator()
{
return new GenericEnumerator(Rows.ToArray());
}
}
数据网格 ItemsSource 是 TimesheetArray。
我遇到的问题是当我为 Employee1 Job1 输入数据时,数据网格看起来像
Work Coding | AL | Sick | Job1 | Job2
____________________________________________
Employee1 | 2 | 2 | 2 | 2
我想要它的样子
Work Coding | AL | Sick | Job1 | Job2
____________________________________________
Employee1 | | | 2 |
数据模板看起来像
<DataTemplate x:Key="TimesheetEntryDetailCellTemplate"
DataType="{x:Type data:TimesheetDetail}">
<Grid>...
<Label Content="ST" />
<TextBox x:Name="txtStandardTime"
Text="{Binding Path=HoursWorked, ...}"></TextBox>
</Grid>
</DataTemplate>
通过调试,我得到了一个 TimesheetDetail[] 对象来绑定
我想我需要类似的东西
<TextBox Text="{Binding Source = TimesheetDetail[ColumnDisplayIndex].HoursWorked}" />
有谁知道如何让单元格模板绑定到它所连接的元素???
提前致谢
【问题讨论】:
标签: wpf arrays datagrid binding matrix