Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit How to run annimation on control in ListBox DataTemplate
2 replies. Latest Post by cbeck on March 18, 2009.
(0)
cbeck
Member
0 points
14 Posts
03-11-2009 2:19 PM |
Thanks to all for help on this so far! One more challenge to go.
I have a structure like the below. I would like to use an animation to change Visibility of "lbInner" to Visible when the mouse enters tbOuter and Collapsed when the mouse leaves tbOuter. Using the VisualTreeHelper to walk the tree I can find lbInner and control the visibility within the mouse events. What I can't get to work is an animation with lbInner as the Target.> I created a StoryBoard as a resource and tried running it (myStoryBoard.Begin()), but it reports "cannot find lbInner".> I added states in Blend and tried using VisualSateManager. It returns false. I assume because it cannot find lbInner.Here is a brief outline of the structure (full XAML is below)<ListBox x:Name="lbOuter"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel x:Name="InnerStackPanel"> <TextBlock x:Name="tbOuter" MouseEnter="tbOuter_MouseEnter" MouseLeave="tbOuter_MouseLeave"/> <ListBox x:Name="lbInner" Visibility="Collapsed"> ... </ListBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate></ListBox>
Here is what the User Control looks like: http://cbeckPhoto.zenfolio.com/p294334137/e1bd43d6cYour thoughts on this are greatly appreciated!Below is the full XAML.
</UserControl>
Mog Lian...
All-Star
15900 points
1,544 Posts
03-15-2009 11:10 PM |
A better way to do this is making tbOuter to be a control derived from Control, then you can use VisualStateManager to implement animation.
I used VisualStateManager in UserControl and seems not work, but in control it works correct.
for more information about Control, refer to this link
http://msdn.microsoft.com/en-us/library/cc278064(VS.95).aspx
03-18-2009 9:38 AM |
Thank you Mog! - I got that working today.