Home Forums Software Development Changing Button Background Color Reply To: Changing Button Background Color


I am sorry for bothering again, but i don’t understand it.
I am not familiar with the different XAML Triggers (DataTrigger, EventSetter, Trigger, …).

In your example, only the Button Color gets changed when the button hasGaze.
In my example, i want to call a function, when onHasGazeChanged. However i don’t know which Trigger to call in the Button Tag.

I tried to add “<EventSetter Event="tobii:Behaviors.HasGazeChanged" Handler="DigitButton_Click" /> to the Style, and tried to read the hasGaze value in my callback function “DigitButton_Click”, but the hasGaze value was always false.

         private void DigitButton_Click(object sender, RoutedEventArgs e)
            var button = e.Source as Button;
            var hasGaze = button.GetHasGaze();
            if (hasGaze)

What am i doing Wrong ?

        <Style x:Key="EyeXGazeAwareElement" TargetType="FrameworkElement">
            <Setter Property="tobii:Behaviors.IsGazeAware" Value="True" />
            <Setter Property="tobii:Behaviors.GazeAwareMode" Value="Delayed" />
            <Setter Property="tobii:Behaviors.GazeAwareDelayTime" Value="900"/>

        <Style x:Key="EyeXGazeAwareButton" BasedOn="{StaticResource EyeXGazeAwareElement}" TargetType="Button">
            <EventSetter Event="tobii:Behaviors.HasGazeChanged" Handler="DigitButton_Click" />
            <Setter Property="Background" Value="{StaticResource DynamicButtonPressColor}" />
                <!-- Trigger my Method somewhere here i guess ? -->
                <Trigger Property="tobii:Behaviors.HasGaze" Value="True">
                    <Setter Property="Background" Value="DeepSkyBlue" />