/// <summary> /// Need to close current popup and open popup if current item has invalid property. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">DataGridItemCancelEventArgs.</param> private void _CollectionViewSourceBeginningEdit(object sender, DataGridItemCancelEventArgs e) { // Do not show callout, when pointing on invalid cell. _StopTimer(); // If callout pointing at another item - close it. if (_InvalidItem != e.Item && _Callout.IsOpen) { _ClosePopup(true); _callout = new Callout(); } // Remember edited item and subscribe to it's property changed event. _InvalidItem = e.Item as IDataErrorInfo; (e.Item as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler (_EditedItemPropertyChanged); // If current column have error. if (_dataGrid.CurrentColumn != null && !string.IsNullOrEmpty((e.Item as IDataErrorInfo)[_dataGrid.CurrentColumn.FieldName])) { // If callout is pointing at another column - close it. if (_column != _dataGrid.CurrentColumn) { _ClosePopup(true); _callout = new Callout(); } // If callout closed - open it and point at current cell. if (!_Callout.IsOpen) { // Detect column to show callout. var column = _dataGrid.CurrentColumn; if (Address.IsAddressPropertyName(column.FieldName)) column = _GetFirstAddressColumn(); _InitCallout(column); } } // If callout closed - seek for item's invalid properties. else if (!_Callout.IsOpen && !string.IsNullOrEmpty(_InvalidItem.Error)) _ShowCalloutOnInvalidItem(e.Item as IDataErrorInfo); // Subscribe to cell property changed events. Doing so we will know when user change active cell. DataRow row = _dataGrid.GetContainerFromItem(e.Item) as DataRow; // If grid view is table flow - even in editing state row can be null. if (row != null) foreach (var cell in row.Cells) cell.PropertyChanged += new PropertyChangedEventHandler(_CellPropertyChanged); }
/// <summary> /// Close current popup, set new popup to _callout field. /// </summary> /// <param name="animate">Animate closing or not.</param> private void _ClosePopup(bool animate) { _Callout.Close(animate); _callout = new Callout(); }