Search code examples
c#silverlightanimationtelerikradtreeview

How do I dynamically turn animations on and off in a Telerik RadTreeView under Silverlight?


I have a Silverlight project where I have a Telerik RadTreeView with checkboxes turned on being used to display and control permissions for a set of users.

Whenever a new user is selected, the checkboxes change their state to reflect the selected user. When this happens, the entire treeview is being refreshed with a new set of the permissions merged with the permission data for that user. The TreeView is recording and re-applying the expanded state of each node when it refreshes for each user.

The problem is that I'd like to have animations turned on, but the animation plays when the TreeView refreshes each time as well. I'd like it to only play when the user manually expands and collapses the nodes.

I'm trying to bind a class to telerik:AnimationManager.IsAnimationEnabled that returns a static property (in another class) that I'm setting to false before each time I re-set the ItemSource, and set back to true immediately after, but the animation still plays every time I select a new user. The class that I'm binding isn't getting hit at all.


Solution

  • Normally you'd do this in the XAML, like you mentioned, but since you want to change these on the fly I'd do the following:

    AnimationManager.IsGlobalAnimationEnabled = false;
    

    and

    AnimationManager.IsGlobalAnimationEnabled = true;
    

    This should give you the results you're looking for.