Search code examples
listboxwindows-phoneselectionchanged

wp7 ListBox SelectionChanged Text Color


The default behaviour for a ListBox used in a WP7 application is for the selected item to be highlighted in the PhoneAccentBrush. I am finding that with a ListBox that when I handle the SelectionChanged event (sets a property and closes popup that contains the ListBox) I never see the text color change to the PhoneAccentBrush - so the user never gets any feedback that they have selected the correct item. Is there a way to work around this and give the user feedback (even though it will only be momentary) as to which item they have selected.


Solution

  • Delay your handling of SelectionChanged event, for example

    void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        Dispatcher.BeginInvoke(action);
    }
    
    void action()
    {
        // put your code here
    }