public static Brush GetHoverRevealBrush(UIElement target) { RadialGradientBrush brush = new(Colors.White, Colors.Transparent) { MappingMode = BrushMappingMode.Absolute, Opacity = 0.0, RadiusX = DefaultRevealBackgroudBrushRadius, RadiusY = DefaultRevealBackgroudBrushRadius }; var binding = new MultiBinding { Converter = new RelativePositionConverter() }; binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.RootObjectProperty) }); binding.Bindings.Add(new Binding() { Source = target }); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.MousePositionProperty) }); BindingOperations.SetBinding(brush, RadialGradientBrush.CenterProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.GradientOriginProperty, binding); RevealBrushHelper.SetRevealBrush(target, brush); return(brush); }
public static Brush GetPressedRevealBrush(UIElement target) { var gradientStops = new GradientStopCollection( new[] { new GradientStop(Color.FromArgb(30, 255, 255, 255), 0), new GradientStop(Color.FromArgb(40, 255, 255, 255), 0), new GradientStop(Colors.Transparent, 1) }); RadialGradientBrush brush = new(gradientStops) { MappingMode = BrushMappingMode.Absolute, Opacity = 0.0, RadiusX = 200.0, RadiusY = 200.0 }; var binding = new MultiBinding { Converter = new RelativePositionConverter() }; binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.RootObjectProperty) }); binding.Bindings.Add(new Binding() { Source = target }); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.MousePositionProperty) }); BindingOperations.SetBinding(brush, RadialGradientBrush.CenterProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.GradientOriginProperty, binding); RevealBrushHelper.SetRevealBrush(target, brush); return(brush); }