我在网格视图中有一个名为'Financial Variance'的字段。仅当“FL费用”和“发票金额”之间存在差异时,才会启用此功能。我需要它,并在启用时显示验证错误。
这是网格的代码
<Grid Grid.Row="2">
<dxg:GridControl
x:Name="xgrdLgVendorInvoiceItem"
Width="Auto"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
FontSize="12"
IsManipulationEnabled="True"
KeyboardNavigation.TabIndex="11"
Loaded="xgrdLgVendorInvoiceItem_Loaded"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectionMode="Row">
<dxb:BarManager.DXContextMenu>
<dxb:PopupMenu>
<dxb:BarButtonItem
x:Name="xbbiAddvLgVendorInvoiceItem"
Content="Add Item"
Glyph="{dx:DXImageGrayscale Image=Add_16x16.png}"
ItemClick="xbbiAddvLgVendorInvoiceItem_ItemClick" />
</dxb:PopupMenu>
</dxb:BarManager.DXContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn
x:Name="xgcChargeType"
Width="120"
MinWidth="80"
AllowEditing="True"
FieldName="LgChargeTypeId"
Header="Charge Type"
HeaderTemplate="{StaticResource bold}">
<dxg:GridColumn.EditSettings>
<dxg:LookUpEditSettings
x:Name="xlueChargeType"
AutoPopulateColumns="False"
DisplayMember="Value"
FilterCondition="Contains"
ImmediatePopup="True"
ValueMember="Key">
<dxg:LookUpEditSettings.PopupContentTemplate>
<ControlTemplate>
<dxg:GridControl x:Name="PART_GridControl">
<dxg:GridControl.Columns>
<dxg:GridColumn
x:Name="xgcChargeTypeId"
FieldName="Key"
Header="Id"
Visible="False" />
<dxg:GridColumn
x:Name="xgcChargeType"
Width="40"
FieldName="Value"
Header="Charge Type" />
<!--<dxg:GridColumn x:Name="xgcBrandName" FieldName="Brand" Header="Brand" Width="150"/>-->
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowBestFit="True" AutoWidth="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</ControlTemplate>
</dxg:LookUpEditSettings.PopupContentTemplate>
</dxg:LookUpEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcInvoiceNumber"
Width="200"
FieldName="LgVendorInvoiceId"
Header="Invoice"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcLgVendorInvoiceItemId"
Width="200"
FieldName="LgVendorInvoiceItemId"
Header="Lg Vendor Invoice Item Id"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcLgVendorInvoiceId"
Width="200"
FieldName="LgVendorInvoiceId"
Header="Lg Vendor Invoice Id"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcChargeTypeId"
Width="200"
FieldName="LgChargeTypeId"
Header="Lg Charge Type Id"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcFLChargeCost"
Width="90"
MinWidth="80"
AllowEditing="False"
FieldName="FLChargeCost"
Header="FL Charge Cost"
HorizontalHeaderContentAlignment="Right"
ReadOnly="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
Mask="C"
MaskType="Numeric"
MaskUseAsDisplayFormat="True" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcInvoiceAmount"
Width="120"
MinWidth="80"
AllowEditing="True"
FieldName="InvoiceAmount"
Header="Invoice Amount"
HeaderTemplate="{StaticResource bold}"
HorizontalHeaderContentAlignment="Right"
ReadOnly="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Center"
Mask="C"
MaskType="Numeric"
MaskUseAsDisplayFormat="True" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcFLChargeId"
Width="90"
MinWidth="40"
AllowEditing="false"
FieldName="FLChargeId"
Header="FL Charge"
HorizontalHeaderContentAlignment="Right"
ReadOnly="False"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcCreatedBy"
Width="200"
FieldName="FullName"
Header="Created By"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcRecordDT"
Width="200"
AllowEditing="False"
FieldName="RecordDT"
Header="Record Date"
HorizontalHeaderContentAlignment="Right"
ReadOnly="True"
Visible="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings
HorizontalContentAlignment="Right"
VerticalContentAlignment="Top"
DisplayFormat="d"
Mask="MM/dd/yyyy"
TextWrapping="NoWrap" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<!--<dxg:GridColumn x:Name="xgcChargeType" FieldName="ChargeType" Header="Charge Type" Width="200" ReadOnly="False" AllowEditing="True" HeaderTemplate="{StaticResource bold}"/>-->
<dxg:GridColumn
x:Name="xgcLgFinancialVarianceTypeId"
Width="138"
MinWidth="80"
AllowEditing="true"
FieldName="LgFinancialVarianceTypeId"
Header="Financial Variance"
ReadOnly="False"
SortIndex="0"
SortOrder="Descending"
Visible="True">
<dxg:GridColumn.EditSettings>
<dxg:LookUpEditSettings
x:Name="xlueFinVarianceType"
AutoPopulateColumns="False"
DisplayMember="Value"
FilterCondition="Contains"
ImmediatePopup="True"
ValueMember="Key">
<dxg:LookUpEditSettings.PopupContentTemplate>
<ControlTemplate>
<dxg:GridControl x:Name="PART_GridControl">
<dxg:GridControl.Columns>
<dxg:GridColumn
x:Name="xgcLgFinancialVarianceTypeId"
FieldName="Key"
Header="Id"
Visible="False" />
<dxg:GridColumn
x:Name="xgcLgFinancialVarianceType"
Width="40"
FieldName="Value"
Header="Financial Variance Type" />
<!--<dxg:GridColumn x:Name="xgcBrandName" FieldName="Brand" Header="Brand" Width="150"/>-->
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowBestFit="True" AutoWidth="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</ControlTemplate>
</dxg:LookUpEditSettings.PopupContentTemplate>
</dxg:LookUpEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn
x:Name="xgcComment"
Width="200"
AllowEditing="True"
FieldName="Comment"
Header="Comment"
HeaderTemplate="{StaticResource bold}"
ReadOnly="False"
Visible="False" />
<!--<dxg:GridColumn x:Name="xgcFinancialVarinace" FieldName="FinancialVariance" Header="Financial Variance" Width="200" ReadOnly="False" AllowEditing="True" HeaderTemplate="{StaticResource bold}"/>-->
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView
x:Name="xgrvLgVendorInvoiceEdit"
AllowCascadeUpdate="True"
AllowColumnFiltering="False"
AllowFilterEditor="False"
AllowFixedGroups="True"
AllowGrouping="True"
CellValueChanged="xgrvvLgVendorInvoiceItem_CellValueChanged"
CellValueChanging="xgrvLgVendorInvoiceEdit_CellValueChanging"
FocusedRowHandleChanged="xgrvLgVendorInvoiceEdit_FocusedRowHandleChanged"
HorizontalScrollbarVisibility="Auto"
MouseRightButtonDown="xgrvLgVendorInvoiceEdit_MouseRightButtonDown"
ShowFixedTotalSummary="True"
ShowGroupPanel="True"
ShowGroupedColumns="True"
ShowTotalSummary="False"
VerticalScrollbarVisibility="Auto">
<!--
ShowingEditor="xgrvvLgVendorInvoiceItem_ShowingEditor"
FocusedColumnChanged="xgrvvLgVendorInvoiceItem_FocusedColumnChanged"
CellValueChanging="xgrvTableView_CellValueChanging"
FocusedRowChanged="xgrvvLgVendorInvoiceItem_FocusedRowChanged"
-->
<dxg:TableView.RowCellMenuCustomizations>
<dxb:BarButtonItem
x:Name="xbbiAddRowvLgVendorInvoiceItem"
Content="Add Item"
Glyph="{dx:DXImageGrayscale Image=Add_16x16.png}"
ItemClick="xbbiAddvLgVendorInvoiceItem_ItemClick" />
<dxb:BarButtonItem
x:Name="xbbiDeletevLgVendorInvoiceItem"
Content="Delete Item"
Glyph="{dx:DXImageGrayscale Image=Remove_16x16.png}"
ItemClick="xbbiDeletevLgVendorInvoiceItem_ItemClick" />
</dxg:TableView.RowCellMenuCustomizations>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
我为另一个设定的规则是
BusinessRules.AddRule(new Csla.Rules.CommonRules.MinValue<Int32>(_ChargeTypeIdProperty, 1, "Charge type required"));