private void GenerateTextAnimations() { mouseEnterTextStoryboard.Children.Clear(); BrushAnimation mouseEnterTextAnimation = new BrushAnimation { From = IsSelected ? SelectedTextBrush : TextBrush, To = TextMouseEnterBrush, Duration = MouseEnterOverAnimationDuration }; Storyboard.SetTarget(mouseEnterTextAnimation, textBlock); Storyboard.SetTargetProperty(mouseEnterTextAnimation, new PropertyPath("Foreground")); mouseEnterTextStoryboard.Children.Add(mouseEnterTextAnimation); mouseLeaveTextStoryboard.Children.Clear(); BrushAnimation mouseLeaveTextAnimation = new BrushAnimation { From = TextMouseEnterBrush, To = IsSelected ? SelectedTextBrush : TextBrush, Duration = MouseEnterOverAnimationDuration }; Storyboard.SetTarget(mouseLeaveTextAnimation, textBlock); Storyboard.SetTargetProperty(mouseLeaveTextAnimation, new PropertyPath("Foreground")); mouseLeaveTextStoryboard.Children.Add(mouseLeaveTextAnimation); }
public void ResetColors() { //используются анимации, тк свойства не работают после использованной анимации if (dockPanel != null) { BrushAnimation backgroundAnimation = new BrushAnimation { From = IsSelected ? SelectedItemBackground : ItemBackground, To = IsSelected ? SelectedItemBackground : ItemBackground, Duration = new Duration(TimeSpan.FromMilliseconds(0)) }; dockPanel.BeginAnimation(DockPanel.BackgroundProperty, backgroundAnimation); } if (textBlock != null) { BrushAnimation textAnimation = new BrushAnimation { From = IsSelected ? SelectedTextBrush : TextBrush, To = IsSelected ? SelectedTextBrush : TextBrush, Duration = new Duration(TimeSpan.FromMilliseconds(0)) }; textBlock.BeginAnimation(TextBlock.ForegroundProperty, textAnimation); } }
public void GenerateBackgroundAnimations() { mouseEnterBackgroundStoryboard.Children.Clear(); BrushAnimation mouseEnterBackgroundAnimation = new BrushAnimation { From = IsSelected ? SelectedItemBackground : ItemBackground, To = ItemMouseEnterBackground, Duration = MouseEnterOverAnimationDuration }; Storyboard.SetTarget(mouseEnterBackgroundAnimation, dockPanel); Storyboard.SetTargetProperty(mouseEnterBackgroundAnimation, new PropertyPath("Background")); mouseEnterBackgroundStoryboard.Children.Add(mouseEnterBackgroundAnimation); mouseLeaveBackgroundStoryboard.Children.Clear(); BrushAnimation mouseLeaveBackgroundAnimation = new BrushAnimation { From = ItemMouseEnterBackground, To = IsSelected ? SelectedItemBackground : ItemBackground, Duration = MouseEnterOverAnimationDuration }; Storyboard.SetTarget(mouseLeaveBackgroundAnimation, dockPanel); Storyboard.SetTargetProperty(mouseLeaveBackgroundAnimation, new PropertyPath("Background")); mouseLeaveBackgroundStoryboard.Children.Add(mouseLeaveBackgroundAnimation); }