private void major_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { BalanceModel bModle = e.AddedItems[0] as BalanceModel; DataGrid thisGrid = sender as DataGrid; if (bModle != null) { this.OnAccountEnvelopeChanged(new AccountEnvelopeChangedEventArgs(bModle.AccountID, bModle.EnvelopeID)); //gridVM.setCurrentAccountEnvelope(bModle.AccountID, bModle.EnvelopeID); e.Handled = true; // Deselect the sub grid if it's not null if (this.prevSubGrid != null) { this.prevSubGrid.SelectedItem = null; } // if (thisGrid != this.prevMajorGrid) { if (this.prevMajorGrid != null) { this.prevMajorGrid.SelectedItem = null; } this.prevMajorGrid = thisGrid; } } } }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { BalanceModel bModel = item as BalanceModel; if (bModel == null || bModel.SubBalances == null || bModel.SubBalances.Count == 0) { return(EmptyTemplate); } else { return(SubBalanceTemplate); } }
private void sub_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { BalanceModel bModle = e.AddedItems[0] as BalanceModel; DataGrid thisGrid = sender as DataGrid; this.prevSubGrid = thisGrid; if (bModle != null) { this.OnAccountEnvelopeChanged(new AccountEnvelopeChangedEventArgs(bModle.AccountID, bModle.EnvelopeID)); } e.Handled = true; } }
private void setSubBalanceColection() { bool envelopes = MyData.getInstance().Account.FindByid(this.AccountID).envelopes; MyObservableCollection <BalanceModel> tempSubs = new MyObservableCollection <BalanceModel>(); if (this._Type == BalanceModel.BalType.Account && envelopes == true) { int[] ids = (from EnvelopeLine in MyData.getInstance().EnvelopeLine where EnvelopeLine.LineItemRow.accountID == this.AccountID select EnvelopeLine.envelopeID).Distinct().ToArray(); foreach (int envID in ids) { BalanceModel bm = new BalanceModel(this.AccountID, envID, true); if (bm.Balance != 0.0m) { tempSubs.Add(bm); } } } else if (this._Type == BalanceModel.BalType.Envelope) { int[] ids = (from EnvelopeLine in MyData.getInstance().EnvelopeLine where EnvelopeLine.envelopeID == this.EnvelopeID select EnvelopeLine.LineItemRow.accountID).Distinct().ToArray(); foreach (int accID in ids) { BalanceModel bm = new BalanceModel(accID, this.EnvelopeID, false); if (bm.Balance != 0.0m) { tempSubs.Add(bm); } } } if (tempSubs.Count > 0) { tempSubs.Sort(new BalanceModelComparer()); this.SubBalances = tempSubs; } }