WPF XCEED DataGrid在一列中有多个属性 [英] WPF XCEED DataGrid multiple property in one column
问题描述
付款 - >付款对象
日期
ID
员工: - > EmpPayment对象的ObservableCollection
Emp A - >和EmpPayment对象
名称
TotalCut - >一个整数Readonly属性,总计削减。
切割 - > Cut对象的集合
Cut1 - >剪切对象1
Cut2 - >剪切对象2
Emp B
名称
TotalCuts
剪切
Cut1
Cut2
我使用的是超级DataGrid。到目前为止这么好,除了我想使用CellContentTemplate在一列中显示两个值,即Cuts和TotalCut。因此,datagrid将如下所示:
员工|削减
Emp A | [总剪切]
剪切1
剪切2
Emp B | [总剪切]
剪切1
剪切2
在剪切列,我想使用Xceed DropDownButton显示总数,用户可以通过编辑dropdowncontent来编辑剪切。到目前为止,我为Employees ObservableCollection创建的XAML:
< xcdg:DataGridControl x:Name =GridEmployeesItemsSource = {Binding Employees}AutoCreateColumns =False>
< xcdg:DataGridControl.Columns>
< xcdg:Column FieldName =NameTitle =Employee/>
< xcdg:Column FieldName =CutsTitle =Cuts>
< xcdg:Column.CellContentTemplate>
< DataTemplate>
< xctk:DropDownButton Content ={Binding Path = TOTALCUT}>
< xctk:DropDownButton.DropDownContent>
< ListBox ItemsSource ={Binding}>
< ListBox.ItemTemplate>
< DataTemplate>
< StackPanel Orientation =Horizontal>
< TextBox Text ={Binding CutDescription}/>
< TextBox Text ={Binding Amount}/>
< / StackPanel>
< / DataTemplate>
< /ListBox.ItemTemplate>
< / ListBox>
< / xctk:DropDownButton.DropDownContent>
< / xctk:DropDownButton>
< / DataTemplate>
< / xcdg:Column.CellContentTemplate>
< / xcdg:列>
< / xcdg:DataGridControl.Columns>
< / xcdg:DataGridControl>
绑定到切割ObservableCollection工作正常,但不是TotalCut。如何将TotalCut [有意写在上面的所有大写字母]绑定到同一列?
使用两列是可能的,但不会很漂亮。
忘记XCeed DataGridControl并欢迎使用标准DataGrid 。只需使用DataGridTemplateColumn。
另一个选择是在XCeed DataGridControl中使用两列,这不是preety。
I have a class which has two level of collections. The software is about salaries payment. The idea is a payment action consists of multiple paid employees. And each employees could have multiple salaries cuts. The Object would look like:
Payment -->Payment Object
Date
ID
Employees: -->ObservableCollection of EmpPayment Objects
Emp A -->And EmpPayment Object
Name
TotalCut --> An Integer Readonly Property that sums the Cuts.
Cuts --> Collection of Cut object
Cut1 --> Cut object 1
Cut2 --> Cut object 2
Emp B
Name
TotalCuts
Cuts
Cut1
Cut2
I am using a exceed DataGrid. So far so good except I want to display two values in one column using CellContentTemplate, that is the Cuts and the TotalCut. So the datagrid will look like:
Employee | Cuts
Emp A | [The Total Cut]
Cut 1
Cut 2
Emp B | [The Total Cut]
Cut 1
Cut 2
At the cuts column, i want to use a Xceed DropDownButton to show the total, and user can edit the cuts by editting the dropdowncontent. So far the XAML i made for the Employees ObservableCollection:
<xcdg:DataGridControl x:Name="GridEmployees" ItemsSource="{Binding Employees}" AutoCreateColumns="False">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Name" Title="Employee"/>
<xcdg:Column FieldName="Cuts" Title="Cuts">
<xcdg:Column.CellContentTemplate>
<DataTemplate>
<xctk:DropDownButton Content="{Binding Path=TOTALCUT}">
<xctk:DropDownButton.DropDownContent>
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding CutDescription}"/>
<TextBox Text="{Binding Amount}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</xctk:DropDownButton.DropDownContent>
</xctk:DropDownButton>
</DataTemplate>
</xcdg:Column.CellContentTemplate>
</xcdg:Column>
</xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
Binding to the Cuts ObservableCollection works well, but not the TotalCut. How do I bind the TotalCut [Intentionally written in all caps above] to that same column? Using two columns is possible, but will not be pretty.
Forget the XCeed DataGridControl and welcome to standard DataGrid. Just use the DataGridTemplateColumn there.
The other alternative is just to use two columns in XCeed DataGridControl which is not preety.
这篇关于WPF XCEED DataGrid在一列中有多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!