/// <summary> /// Adds the specified transition provider to the supported ones. /// </summary> /// <param name="provider"> /// The <see cref="IVisualTransitionProvider"/> to be added to the providers /// which are used by the <see cref="ExtendedVisualStateManager"/>. /// </param> public static void AddProvider(IVisualTransitionProvider provider) { if (provider != null) { _transitionProviders.Add(provider); } }
private static bool TryFindRegisteredProviderForTimeline( Timeline timeline, out IVisualTransitionProvider result) { // Go through the list from behind to allow overwriting of the standard providers. for (int i = _transitionProviders.Count - 1; i >= 0; i--) { IVisualTransitionProvider currentProvider = _transitionProviders[i]; if (currentProvider.SupportsTimeline(timeline)) { result = currentProvider; return(true); } } result = null; return(false); }
/// <summary> /// Tries to return a registered <see cref="IVisualTransitionProvider"/> which supports /// the specified <paramref name="timeline"/>. /// If a provider was found, this method returns <c>true</c> and stores the provider /// in the <paramref name="result"/> parameter. /// If none was found, this method returns <c>false</c> and <paramref name="result"/> /// is set to <c>null</c>. /// </summary> /// <param name="timeline"> /// The <see cref="Timeline"/>. /// </param> /// <param name="result"> /// An <see cref="IVisualTransitionProvider"/> which will hold the result of this method. /// </param> /// <returns> /// A <see cref="Boolean"/> indicating whether getting a provider succeeded; /// </returns> public static bool TryGetProviderForTimeline(Timeline timeline, out IVisualTransitionProvider result) { if (timeline == null) { throw new ArgumentNullException(nameof(timeline)); } // Allow timelines to implement the interface themselves. // This allows them to generate the transitions on their own, without an external class. // This is, for example, used by the FromToByAnimationBase, which automatically provides // custom transitions for each animation that derives from it. if (timeline is IVisualTransitionProvider selfAwareTimelineProvider && selfAwareTimelineProvider.SupportsTimeline(timeline)) { result = selfAwareTimelineProvider; return(true); } // If the timeline doesn't self provide the values, check for a registered provider. return(TryFindRegisteredProviderForTimeline(timeline, out result)); }