Hi,
I'm working at a custom control in WPF. This control should work as menu with buttons. The buttons are on left side of the window
(4..5 one below the other) and realized by rectangles.
At the first time I used triggers with setters to set the colors of the rectangle
( Button Enabled = DarkBlue,
Button Disabled = LightBlue,
MouseOver = MiddleBlue).
This worked fine for every button. If the mouse was over the enabled buttons, the button color became middleblue and by leaving
the button, the button became darkblue. The disabled button was always lightblue. If I switched the buttons from enable to disable, the previous button became dark blue and the IsMouseOver works again.
But now, I decided to animate the rectangles by color transition. Now I'm using the MultiTrigger to animate the color transition.
But it doesn't work. When starting the application the button at the top is disabled. If I click the next button under the button at the top, the clicked button becomes disable (lightblue) and the top button becomes enabled (darkblue). Now the IsMouseOver
property doesn't work for the first button in the top. But it works already for the buttons I never clicked.
I think, that the disabled button, which becomes enable again, ignores the MouseOver property.
How can I solve this problem? Image may be NSFW.
Clik here to view.
Here is the code:
<!-- Set properties when mouse pointer is over the button. --><MultiTrigger> <MultiTrigger.Conditions><Condition Property="IsEnabled" Value="True" /> <Condition Property="IsMouseOver" Value="True" /></MultiTrigger.Conditions><!-- Happens when the mouse cursor enter the button area --><MultiTrigger.EnterActions><BeginStoryboard><Storyboard><!-- rectangle - changing color to middle blue --><ColorAnimation Storyboard.TargetName="rightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).Color" To="{StaticResource colorMiddleBlue}" Duration="0:0:0.25" /></Storyboard></BeginStoryboard></MultiTrigger.EnterActions><!-- Happens when the mouse cursor leaves the button --><MultiTrigger.ExitActions><BeginStoryboard><Storyboard><ColorAnimation Storyboard.TargetName="rightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).Color" To="{StaticResource colorDarkBlue}" Duration="0:0:0.20" /></Storyboard></BeginStoryboard></MultiTrigger.ExitActions> </MultiTrigger><!-- Disabled Button--><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsEnabled" Value="False"/></MultiTrigger.Conditions><MultiTrigger.EnterActions><BeginStoryboard><Storyboard><ColorAnimation Storyboard.TargetName="rightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).Color" Duration="0:0:0.15" To="{StaticResource colorLightBlue}" /></Storyboard></BeginStoryboard></MultiTrigger.EnterActions><MultiTrigger.ExitActions><BeginStoryboard><Storyboard><ColorAnimation Storyboard.TargetName="rightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).Color" Duration="0:0:0.15" To="{StaticResource colorDarkBlue}" /></Storyboard></BeginStoryboard></MultiTrigger.ExitActions></MultiTrigger>