DataTable移除行
strFilter = "PaymentDate = '" + DateTime.MinValue + "' OR PaymentAmount = '" + decimal.Zero +
"' OR VC_PaymentMode = '" + string.Empty +
"' OR VC_PaymentMode IS NULL ";
DataRow[] drsIncompleteData = null;
drsIncompleteData = _Model.PurchasePaymentItemEntityList.GetEntityDataTable().Select(strFilter);
foreach (var dr in drsIncompleteData)
{
_Model.PurchasePaymentItemEntityList.GetEntityDataTable().Rows.Remove(dr);
}
2.模板列触发
<DataGrid x:Name="dgPaymentItem"
Style="{DynamicResource DataGridStyle}"
RowStyle="{DynamicResource DataGridRowStyle}"
ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle1}"
CanUserAddRows="False" SelectionMode="Single"
ItemsSource="{Binding Path=PurchasePaymentItemEntityList}"
IsReadOnly="{Binding Path=PurchaseOrderEntity.IsClosed, Converter={StaticResource BooleanToReadOnlyConverter}}"
<DataTemplate.Triggers>
<DataTrigger
Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=IsReadOnly}"
Value="True">
<Setter TargetName="btnDeletePayment" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
3.WPF拖动DataGrid滚动条时内容混乱的解决方法
在WPF中,如果DataGrid里使用了模板列,当拖动滚动条时,往往会出现列表内容显示混乱的情况。解决方法就是在Binding的时候给UpdateSourceTrigger赋值。