static CirclePointRingLoading() { BindableWidthProperty = DependencyProperty.Register("BindableWidth", typeof(double), typeof(CirclePointRingLoading), new PropertyMetadata(0.0, BindableWidthCallback)); IsActiveProperty = DependencyProperty.Register("IsActive", typeof(bool), typeof(CirclePointRingLoading), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsActiveChanged)); IsLargeProperty = DependencyProperty.Register("IsLarge", typeof(bool), typeof(CirclePointRingLoading), new PropertyMetadata(true, IsLargeChangedCallback)); MaxSideLengthProperty = DependencyProperty.Register("MaxSideLength", typeof(double), typeof(CirclePointRingLoading), new PropertyMetadata(0.0)); EllipseDiameterProperty = DependencyProperty.Register("EllipseDiameter", typeof(double), typeof(CirclePointRingLoading), new PropertyMetadata(0.0)); EllipseOffsetProperty = DependencyProperty.Register("EllipseOffset", typeof(Thickness), typeof(CirclePointRingLoading), new PropertyMetadata(default(Thickness))); FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(CirclePointRingLoading), new FrameworkPropertyMetadata(typeof(CirclePointRingLoading))); UIElement.VisibilityProperty.OverrideMetadata(typeof(CirclePointRingLoading), new FrameworkPropertyMetadata(delegate(DependencyObject ringObject, DependencyPropertyChangedEventArgs e) { if (e.NewValue != e.OldValue) { CirclePointRingLoading circlePointRingLoading = (CirclePointRingLoading)ringObject; if ((Visibility)e.NewValue != 0) { circlePointRingLoading.SetCurrentValue(IsActiveProperty, false); } else { circlePointRingLoading.IsActive = true; } } })); }
private static void IsLargeChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { CirclePointRingLoading circlePointRingLoading = sender as CirclePointRingLoading; if (circlePointRingLoading != null) { circlePointRingLoading.UpdateLargeState(); } }
private static void BindableWidthCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { CirclePointRingLoading circlePointRingLoading = dependencyObject as CirclePointRingLoading; if (circlePointRingLoading != null) { circlePointRingLoading.SetEllipseDiameter((double)e.NewValue); circlePointRingLoading.SetEllipseOffset((double)e.NewValue); circlePointRingLoading.SetMaxSideLength((double)e.NewValue); } }