我有一个允许记录过滤的XamDataGrid。第一个字段是“Selected”复选框,其余字段只是我在网格中显示的对象的数据。在代码方面,它看起来像这样:
<igWPF:XamDataGrid x:Name="xamDataGrid"
DataSource="{Binding SomeDataSourceInTheViewModels}">
<!-- XamDataGrid Settings -->
<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings FilterAction="Hide"
FilterUIType="LabelIcons"/>
</igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:XamDataGrid.FieldSettings>
<igWPF:FieldSettings ...
AllowRecordFiltering="True"
FilterOperatorDefaultValue="Equals"
FilterLabelIconDropDownType="MultiSelectExcelStyle"
.../>
</igWPF:XamDataGrid.FieldSettings>
<!-- XamDataGrid Field layout -->
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:Field Label="Selected" Name="Selected" Width="Auto">
<!-- Select/Unselect all button -->
<igWPF:Field.Settings>
<igWPF:FieldSettings AllowEdit="True">
<igWPF:FieldSettings.LabelPresenterStyle>
<Style TargetType="{x:Type igWPF:LabelPresenter}" BasedOn="{StaticResource {x:Type igWPF:LabelPresenter}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igWPF:LabelPresenter}">
<!-- The Select all checkbox -->
<CheckBox />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igWPF:FieldSettings.LabelPresenterStyle>
</igWPF:FieldSettings>
</igWPF:Field.Settings>
</igWPF:Field>
<!-- The rest of the fields -->
<igWPF:Field Label="SomeIntValue" Name="SomeIntValue" Width="Auto"/>
<igWPF:Field Label="SomeBoolValue" Name="SomeBoolValue" Width="Auto" />
<igWPF:Field Label="SomeStringValue" Name="SomeStringValue" Width="Auto" />
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
</igWPF:XamDataGrid>
我的最终目标是在Selected
列上方的数据网格顶部有一个复选框,我可以单击并选择所有未过滤的行。我对如何实现它的新想法持开放态度,但我的问题是:如何在代码隐藏或ViewModel中循环遍历所有未过滤的行?
我知道某处有一个“IsFilteredOut”属性,但在xamDataGrid
找不到它
RecordManager的GetFilteredOutDataRecords()方法返回所有未传递记录过滤条件的数据记录:
foreach(var rec in xamDataGrid.RecordManager.GetFilteredOutDataRecords())
{
// TODO: ...
}
希望有所帮助。