Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows phone 7 ListBox animation on selection

I have a ListBox in my application that contains TextBlocks displaying some data. The TextBlocks are setup to fire an event when the user clicks on them.

<ListBox x:Name="ListBoxCategories"
         Margin="0,0,-12,0"
         ItemsSource="{Binding ListBoxItems}">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <StackPanel Margin="0,0,0,17"
                  Width="432">
        <TextBlock Text="{Binding ItemName}"
                   TextWrapping="Wrap"
                   MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"
                   Style="{StaticResource PhoneTextLargeStyle}"
                   Foreground="{StaticResource PhoneAccentBrush}" />
      </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

This works as I want it to, but it'd be great if I could provide some sort of animation when the user clicks on an item. For instance, when you select a contact from the phone's address book and click on one of the actions (such as "send email" or "call mobile") the text briefly moves before the selected action is performed. Is there any way of doing this?

like image 704
Praetorian Avatar asked Dec 13 '10 04:12

Praetorian


1 Answers

  1. Create a story board with blend to move the text box.

  2. Start the story board from the click event handler.

  3. Perform your action in the story board finished event.

like image 152
Amr H. Abd Elmajeed Avatar answered Oct 06 '22 00:10

Amr H. Abd Elmajeed