/// <summary> /// Gets the property value as a fake attached property. /// </summary> /// <param name="d">The object upon which to set a value.</param> /// <param name="property">The name of the property to set.</param> /// <returns>The property value, or <c>null</c> if not found.</returns> public static object GetPropertyValue(this IFakeDependencyObject d, string property) { object value = null; var visual = d as OSVisualBase; if (visual != null) { visual.GetInheritedValue(property, out value); } else { d.GetValue(property, out value); } return(value); }
/// <summary> /// Sets the special DataContext property. /// </summary> /// <param name="d">A fake 'DependencyObject'-like object upon which to set the DataContext property.</param> /// <param name="value">The value of the DataContext.</param> /// <param name="propertyChanged">Adds this event handler to the <paramref name="value"/>'s PropertyChanged event. This requires that /// the type of <paramref name="value"/> implement the <see cref="INotifyPropertyChanged"/> interface.</param> public static void SetDataContextWithDataContextPropertyChangedHandler(this IFakeDependencyObject d, object value, PropertyChangedEventHandler propertyChanged) { d.SetDataContext(value); ((INotifyPropertyChanged)value).PropertyChanged += propertyChanged; }
/// <summary> /// Sets the special DataContext property. /// </summary> /// <param name="d">A fake 'DependencyObject'-like object upon which to set the DataContext property.</param> /// <param name="value">The value of the DataContext.</param> /// <param name="propertyChanged">If not <c>null</c>, this method is invoked if the value of <paramref name="value"/> is changed.</param> public static void SetDataContext(this IFakeDependencyObject d, object value, PropertyChangedEventHandler propertyChanged) { d.SetPropertyValue(DataContextPropertyName, value, propertyChanged); }
/// <summary> /// Sets the special DataContext property. /// </summary> /// <param name="d">A fake 'DependencyObject'-like object upon which to set the DataContext property.</param> /// <param name="value">The value of the DataContext.</param> public static void SetDataContext(this IFakeDependencyObject d, object value) { d.SetPropertyValue(DataContextPropertyName, value, null); }
/// <summary> /// Gets the special DataContext property. /// </summary> /// <param name="d">A fake 'DependencyObject'-like object from which to read the DataContext property.</param> /// <returns>The value of the DataContext property.</returns> public static object GetDataContext(this IFakeDependencyObject d) { return(d.GetPropertyValue(DataContextPropertyName)); }