private static void OnBindingValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var field = (FeatureDataField)d; // if require information is missing return. if (string.IsNullOrEmpty(field.FieldName) || field.GeodatabaseFeature == null || field.GeodatabaseFeature.Attributes == null) { field.ValidationException = null; return; } #if !NETFX_CORE // WPF will raise this event even if the new value // is same as old value. WinRT and WP8 will only // raise this event if the new value is not the same // as the old value. This code is to enusre equality // in behavior accross all platforms. if (AreEqual(e.NewValue, e.OldValue)) { // clear out any previous validation exception. field.ValidationException = null; return; } #endif // Update the UI controls data context object to the current value. if (field._dataItem != null && !AreEqual(field._dataItem.Value,e.NewValue)) { field._dataItem.Value = (field._dataItem is SelectorDataItem) ? ((SelectorDataItem) field._dataItem).SelectItem(e.NewValue) : field._dataItem.Value = e.NewValue; } var oldValue = field.GeodatabaseFeature.Attributes.ContainsKey(field.FieldName) ? field.GeodatabaseFeature.Attributes[field.FieldName] : null; if ( AreEqual(oldValue, field.BindingValue)) { // clear out any previous validation exception. field.ValidationException = null; return; } // if value changing event is subscribed to raise event. if (field.ValueChanging != null) { var changing = new ValueChangingEventArgs(oldValue, field.BindingValue); // raise value changing event. field.ValueChanging(field, changing); // if ValueChangeEventArgs return with the validation exception property // set then the user has indicated that the new value doesn't not meet // some user defined validation requirement and the validation state // should be trigger with the provided Exception. if (changing.ValidationException != null) { // Set the users exception to the FeatureDataField.ValidationException property. // This will trigger the validation state. field.ValidationException = changing.ValidationException; return; } } #if NETCORE_FX // clear out any previous validation exception. form.ValidationException = null; #endif // Attempt to update the new value back to the GeodatabaseFeature var success = field.CommitChange(field.BindingValue); // if the ValueChanged event is subscribed to and the committed value was // successfully pushed back to the GeodatabaseFeature then rais the ValueChanged Event. if (field.ValueChanged != null && success) field.ValueChanged(field, new ValueChangedEventArgs(oldValue, field.BindingValue)); field.OnPropertyChanged("BindingValue"); }
private static void OnBindingValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var field = (FeatureDataField)d; // if require information is missing return. if (string.IsNullOrEmpty(field.FieldName) || field.GeodatabaseFeature == null || field.GeodatabaseFeature.Attributes == null) { field.ValidationException = null; return; } #if !NETFX_CORE // WPF will raise this event even if the new value // is same as old value. WinRT and WP8 will only // raise this event if the new value is not the same // as the old value. This code is to enusre equality // in behavior accross all platforms. if (AreEqual(e.NewValue, e.OldValue)) { // clear out any previous validation exception. field.ValidationException = null; return; } #endif // Update the UI controls data context object to the current value. if (field._dataItem != null && !AreEqual(field._dataItem.Value, e.NewValue)) { field._dataItem.Value = (field._dataItem is SelectorDataItem) ? ((SelectorDataItem)field._dataItem).SelectItem(e.NewValue) : field._dataItem.Value = e.NewValue; } var oldValue = field.GeodatabaseFeature.Attributes.ContainsKey(field.FieldName) ? field.GeodatabaseFeature.Attributes[field.FieldName] : null; if (AreEqual(oldValue, field.BindingValue)) { // clear out any previous validation exception. field.ValidationException = null; return; } // if value changing event is subscribed to raise event. if (field.ValueChanging != null) { var changing = new ValueChangingEventArgs(oldValue, field.BindingValue); // raise value changing event. field.ValueChanging(field, changing); // if ValueChangeEventArgs return with the validation exception property // set then the user has indicated that the new value doesn't not meet // some user defined validation requirement and the validation state // should be trigger with the provided Exception. if (changing.ValidationException != null) { // Set the users exception to the FeatureDataField.ValidationException property. // This will trigger the validation state. field.ValidationException = changing.ValidationException; return; } } #if NETCORE_FX // clear out any previous validation exception. form.ValidationException = null; #endif // Attempt to update the new value back to the GeodatabaseFeature var success = field.CommitChange(field.BindingValue); // if the ValueChanged event is subscribed to and the committed value was // successfully pushed back to the GeodatabaseFeature then rais the ValueChanged Event. if (field.ValueChanged != null && success) { field.ValueChanged(field, new ValueChangedEventArgs(oldValue, field.BindingValue)); } field.OnPropertyChanged("BindingValue"); }