<TextBox >>> Name="txtAirWayBillTotal" >>> Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=AirWayBillTotal}" >>> Grid.Column="3" >>> Grid.Row="5" >>> Height="23" >>> HorizontalAlignment="Stretch" >>> Margin="0" >>> VerticalAlignment="Top" >>> Width="Auto" >>> Grid.ColumnSpan="2" >>> HorizontalContentAlignment="Right" >>> FontWeight="Bold" IsReadOnly="True" Focusable="False" />>>>
private decimal airwaybillTotal; >>> >>> public decimal AirWayBillTotal >>> { >>> get >>> { >>> return this.airwaybillTotal; >>> } >>> >>> set >>> { >>> if (value != this.airwaybillTotal) >>> { >>> this.airwaybillTotal = value; >>> this.OnPropertyChanged("AirWayBillTotal"); >>> } >>> } >>> } >>>>>>
void AirWayBillDetail_StateChange(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) >>> { >>> if (e.State == mmBusinessState.Retrieved) >>> { >>> // Store the Air WayBill Detail in the DataGrid's data context >>> this.grdAirWayBillDetails.DataContext = this.AirWayBillDetail.EntityList; >>> >>> // Hide the new item row place holder in the Air WayBill Detail DataGrid >>> ((IEditableCollectionView)CollectionViewSource.GetDefaultView(grdAirWayBillDetails.ItemsSource)).NewItemPlaceholderPosition = >>> NewItemPlaceholderPosition.None; >>> } >>> //this.ShowAirWayBillTotal(); >>> if (this.AirWayBillDetail.EntityList != null) >>> { >>> this.AirWayBillTotal = this.AirWayBillDetail.EntityList.Sum(x => x.awd_amount); >>> foreach (var c in this.AirWayBillDetail.EntityList) >>> { >>> c.PropertyChanged += CollectionItemChanged; >>> } >>> } >>> >>> }>>>
void CollectionItemChanged(object sender, PropertyChangedEventArgs e) >>> { >>> if (e.PropertyName == "awd_amount") >>> { >>> AirWayBillTotal = AirWayBillDetail.EntityList.Sum(x => x.awd_amount); >>> OnPropertyChanged("AirWayBillTotal"); >>> } >>> }>>>
<DataGrid AutoGenerateColumns="False" Grid.Row="1" Grid.Column="3" > Height="Auto" > HorizontalAlignment="Stretch" > Margin="0" > Name="grdCourierAirWayBillDetails" > VerticalAlignment="Stretch" > Width="Auto" > IsSynchronizedWithCurrentItem="True" > ItemsSource="{Binding Mode=default}" > SelectionMode="Single" > GridLinesVisibility="None" > HeadersVisibility="Column" > Grid.ColumnSpan="2" > > CanUserAddRows="False" > CanUserDeleteRows="False" > SelectionUnit="Cell" > Grid.RowSpan="4"> > <DataGrid.Resources> > <Style x:Key="AlignRight" TargetType="DataGridCell"> > <Setter Property="HorizontalAlignment" Value="Right" /> > > </Style> > <Style x:Key="AlignRightHeader" TargetType="DataGridColumnHeader"> > <Setter Property="HorizontalAlignment" Value="Right" /> > </Style> > </DataGrid.Resources> > <DataGrid.Columns> > <DataGridComboBoxColumn Header="Charge Type" Width="2*" > DisplayMemberPath="cty_name" > SelectedValuePath="cty_pk" > SelectedValueBinding="{Binding cwd_ctyfk, Mode=Default}"/> > > <DataGridTextColumn Header="Amount" Width="*" Binding="{Binding cwd_amount, Mode=default}" > CellStyle="{StaticResource AlignRight}" > HeaderStyle="{StaticResource AlignRightHeader}"/> > </DataGrid.Columns> > </DataGrid>>
<DataGridTextColumn Header="Amount" Width="*" Binding="{Binding cwd_amount, Mode=default, UpdateSourceTrigger=PropertyChanged}" CellStyle="{StaticResource AlignRight}" HeaderStyle="{StaticResource AlignRightHeader}"/>