Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1013415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:05:54+00:00 2026-05-16T10:05:54+00:00

I’ve got a WPF app that has a listbox which I’m trying to apply

  • 0

I’ve got a WPF app that has a listbox which I’m trying to apply some mouseover effects to. It all works fine when I use simple Setters to change the background color on mouseover/selection, but I figured it would look nicer if it animated between states, so I switched the Setters for enter/exit Storyboards. It all works nicely initially (mouseover animates in & out, selection animates in & out), but once something has been selected and then become deselcted, it will never do the mouseover effect again.

Here’s the minimal code example to show the issue:

<Window x:Class="WpfTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="500" Width="500">
  <Window.Resources>
    <Style x:Key="ListboxItemStyle" TargetType="{x:Type ListBoxItem}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}">
            <Border x:Name="border" BorderThickness="1" Height="50" Background="#000">
              <ContentPresenter />
            </Border>
            <ControlTemplate.Triggers>
              <MultiTrigger>
                <MultiTrigger.Conditions>
                  <Condition Property="IsMouseOver" Value="True" />
                  <Condition Property="IsSelected" Value="False" />
                </MultiTrigger.Conditions>
                <MultiTrigger.EnterActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation Duration="0:0:0.15" Storyboard.TargetName="border"
                          Storyboard.TargetProperty="Background.Color" To="#00F" />
                    </Storyboard>
                  </BeginStoryboard>
                </MultiTrigger.EnterActions>
                <MultiTrigger.ExitActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="border"
                          Storyboard.TargetProperty="Background.Color" To="#008" />
                    </Storyboard>
                  </BeginStoryboard>
                </MultiTrigger.ExitActions>
              </MultiTrigger>
              <Trigger Property="IsSelected" Value="True">
                <Trigger.EnterActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation Duration="0:0:0.15" Storyboard.TargetName="border"
                          Storyboard.TargetProperty="Background.Color" To="#F00" />
                    </Storyboard>
                  </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="border"
                          Storyboard.TargetProperty="Background.Color" To="#800" />
                    </Storyboard>
                  </BeginStoryboard>
                </Trigger.ExitActions>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </Window.Resources>
  <Grid>
    <ListBox x:Name="ConnectedDevicesListBox"
        ItemContainerStyle="{DynamicResource ListboxItemStyle}" >
      <ListItem/>
      <ListItem/>
      <ListItem/>
      <ListItem/>
      <ListItem/>
      <ListItem/>
      <ListItem/>
      <ListItem/>
    </ListBox>
  </Grid>
</Window>

I’ve made the exit animations fade to a non-black color so you can see that the it’s getting stuck after the IsSelected exit storyboard.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:05:54+00:00Added an answer on May 16, 2026 at 10:05 am

    The default behavior of a Storyboard is to continue setting the property value to value from the last frame of the animation. See Animation Tips and Tricks, especially the “Can’t Change the Value of a Property after Animating it” section. You are never stopping the storyboards, so eventually they are all running and whichever one is declared last is setting the final value.

    You can set the FillBehavior of the Storyboards to Stop so that the Storyboard will stop setting the value after it completes. I think you will want to do this on the ExitActions storyboards, but not on the EnterAction storyboards unless you also set the background color with a normal trigger. Something like this:

    <MultiTrigger>
        <MultiTrigger.Conditions>
            <Condition Property="IsMouseOver" Value="True" />
            <Condition Property="IsSelected" Value="False" />
        </MultiTrigger.Conditions>
        <MultiTrigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                    <ColorAnimation Duration="0:0:0.15"
                        Storyboard.TargetName="border"
                        Storyboard.TargetProperty="Background.Color" To="#00F" />
                </Storyboard>
            </BeginStoryboard>
        </MultiTrigger.EnterActions>
        <MultiTrigger.ExitActions>
            <BeginStoryboard>
                <Storyboard FillBehavior="Stop">
                    <ColorAnimation Duration="0:0:0.3"
                        Storyboard.TargetName="border"
                        Storyboard.TargetProperty="Background.Color" To="#008" />
                </Storyboard>
            </BeginStoryboard>
        </MultiTrigger.ExitActions>
    </MultiTrigger>
    <Trigger Property="IsSelected" Value="True">
        <Trigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                    <ColorAnimation Duration="0:0:0.15"
                        Storyboard.TargetName="border"
                        Storyboard.TargetProperty="Background.Color" To="#F00" />
                </Storyboard>
            </BeginStoryboard>
        </Trigger.EnterActions>
        <Trigger.ExitActions>
            <BeginStoryboard>
                <Storyboard FillBehavior="Stop">
                    <ColorAnimation Duration="0:0:0.3"
                        Storyboard.TargetName="border"
                        Storyboard.TargetProperty="Background.Color" To="#800" />
                </Storyboard>
            </BeginStoryboard>
        </Trigger.ExitActions>
    </Trigger>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.