1

I have a button, and when the mouse goes over it, I'd like to swap the foreground and background colors. (The original foreground and background are inherited from the parent control.) I have written the code below:

<Style TargetType="Button">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Mode=OneTime}"/>
            <Setter Property="Foreground" Value="Black"/>
        </Trigger>
    </Style.Triggers>
</Style>

But when the mouse moves over the button, the entire element goes black! Is there a way to force the one time binding on Background to finish before Foreground is set to black (sequentially)?

bwall
  • 984
  • 8
  • 22

0 Answers0