这是我关于StackOverflow的第一个问题,所以我希望我没有做错任何事情!抱歉,是这样!我需要一些帮助,因为找不到解决方案。当然,我已经在网上到处搜索了,但是找不到(由于声誉低下的原因,我无法发布正在使用的链接:()。此外,我还是C#和WPF(和自学)的新手。我以前使用C ++ / Qt工作,所以我不知道在WPF中如何工作,对不起我的英语,我是法语。
我的基本课程是员工可以使用计算机。计算机的ID和使用日期存储在类中Connection
。我想像这样在DataGrid和RowDetailsTemplate中显示列表信息:
因此,它将绑定到Employee
类,但也绑定到Connection
仅具有属性的最后一个值的类(此处是最后一台计算机上列表“ Computer ID”的最后一个值和列表“ Connection Date”的最后一个值) 。因此,这是不同列表中的循环。我该怎么做 ?
要做太多了吗?:(我成功获取了Employee信息,但是我不知道如何绑定计算机列表。在尝试时,它显示为“(Collection)”,因此它不会进入列表内:(
DataGrid
?RowDetailsTemplate
?在Windows 7和Visual Studio 2010 Pro版本下。
如果您尚未使用MVVM模式,我建议您熟悉一下...这是非常基本的,因此您想要对其进行修改/样式化以获得所需的^ _ ^ ...
<DataGrid ItemsSource="{Binding Employees}">
<DataGrid.Columns>
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/>
<DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/>
<DataGridTextColumn Header="Gender" Binding="{Binding Gender}"/>
<DataGridTextColumn Header="Last computer used" Binding="{Binding LastComputerUsed}"/>
<DataGridTextColumn Header="Last connection date" Binding="{Binding LastConnectionDate}"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding ComputerIDs}">
<DataGrid.Columns>
<DataGridTextColumn Header="Computer ID" Binding="{Binding ID}"/>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListView ItemsSource="{Binding ConnectionDates}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句