/// <summary> /// Initializes a new instance of the <see cref="RelayObject"/> class. /// </summary> /// <param name="listener">The listener.</param> public RelayObject(DependencyPropertyChangedListener listener) { _listener = listener; }
private void OnFilterDescriptorChanged() { if (_filterDescriptorMemberChangedListener != null) { _filterDescriptorMemberChangedListener.Detach(); _filterDescriptorMemberChangedListener.ValueChanged -= OnMemberChanged; _filterDescriptorMemberChangedListener = null; } if (FilterDescriptor != null) { _filterDescriptorMemberChangedListener = DependencyPropertyChangedListener.Create( FilterDescriptor, ReflectionHelper.GetPropertyName<FilterDescriptor>(x => x.Member)); _filterDescriptorMemberChangedListener.ValueChanged += OnMemberChanged; } PopulateMemberSelectors(); }
/// <summary> /// Creates a new instance of <see cref="DependencyPropertyChangedListener" />. /// </summary> /// <param name="sourceElement">The source element.</param> /// <param name="propertyPath">The property path.</param> /// <returns>The <see cref="DependencyPropertyChangedListener" />.</returns> /// <exception cref="System.ArgumentNullException">sourceElement</exception> /// <exception cref="System.ArgumentException">propertyPath is empty.</exception> /// <exception cref="ArgumentNullException">The <paramref name="sourceElement" /> parameter is null.</exception> /// <exception cref="ArgumentException">The <paramref name="propertyPath" /> is null or whitespace.</exception> public static DependencyPropertyChangedListener Create(DependencyObject sourceElement, string propertyPath) { if (sourceElement == null) throw new ArgumentNullException("sourceElement"); if (string.IsNullOrWhiteSpace(propertyPath)) throw new ArgumentException("propertyPath is empty."); var listener = new DependencyPropertyChangedListener(); var binding = new Binding(propertyPath) { Source = sourceElement, Mode = BindingMode.OneWay }; var relay = new RelayObject(listener); listener.RelayInstance = relay; BindingOperations.SetBinding(relay, RelayObject.ValueProperty, binding); return listener; }