Search code examples
silverlightwindows-phone-7

Animate ListBoxItem on Load


I have a list where I want to animate (blink) the last selected item (obtained from state) on page load. It is a databound listbox. How do we do it traditionally? How do we do it in MVVM?


Solution

  • The way I would go about it is to have a ViewModel Property that oscillates between 0 and 1 at increments of 0.01 ~ 0.05, depending on how slow/fast you want the transition, and bind that property to the opacity in the SelectedItemTemplate.

    To attain "oscillation", you can use something temporal. (DateTime.Now.Second / 60) during "even" minutes and (60 - DateTime.Now.Second) / 60 during "odd" minutes

    No extra infrastructure or coding needed. Since our measuring stick is time you can adjust accordingly for the appropriate frequency and speed.