Esempio n. 1
0
        private void FindStoryboard(string stateName)
        {
            DisposeEventHandlers();

            var groups = VisualStateManager.GetVisualStateGroups(LayoutRootPart);

            var transitionState = (from VisualStateGroup visualStateGroup in groups
                                   from VisualState state in visualStateGroup.States
                                   where visualStateGroup.Name == TransitionStatesGroupName
                                   where state.Name == stateName
                                   select state).FirstOrDefault();

            if (transitionState == null)
            {
                return;
            }

            switch (stateName)
            {
            case BeforeLoadedStateName:
                beforeLoadedEvents = new WeakStoryboardEvents(this, transitionState.Storyboard);
                break;

            case LoadedStateName:
                loadedEvents = new WeakStoryboardEvents(this, transitionState.Storyboard);
                break;

            case UnloadedStateName:
                unloadedEvents = new WeakStoryboardEvents(this, transitionState.Storyboard);
                break;
            }
        }
Esempio n. 2
0
 private void DisposeEventHandlers()
 {
     if (beforeLoadedEvents != null)
     {
         beforeLoadedEvents.Dispose();
         beforeLoadedEvents = null;
     }
     if (loadedEvents != null)
     {
         loadedEvents.Dispose();
         loadedEvents = null;
     }
     if (unloadedEvents != null)
     {
         unloadedEvents.Dispose();
         unloadedEvents = null;
     }
 }