public void DoTransition(object newContent, ITransition transition) { if (newContent == null) { Children.Clear(); return; } UIElement view; if (ContentTemplate != null) { var template = ContentTemplate.LoadContent(); var fe = template as FrameworkElement; if (fe != null) { fe.DataContext = newContent; } view = template as UIElement; } else { view = newContent as UIElement; } if (view == null) { return; } if (Children.Count > 0) { if (transition.RequiresNewContentTopmost) { Children.Add(view); transition.BeginTransition(this, Children[0], view); } else { Children.Insert(0, view); transition.BeginTransition(this, Children[1], view); } } else { Children.Add(view); TransitionEnded(transition, null, view); } }
/// <summary> /// Starts the specified transition. /// </summary> /// <param name="previousContent"></param> /// <param name="newContent"></param> /// <param name="transition"></param> public void DoTransition(UIElement previousContent, UIElement newContent, ITransition transition) { Children.Clear(); Children.Add(previousContent); if (transition.RequiresNewContentTopmost) { if (newContent != null) Children.Add(newContent); transition.BeginTransition(this, Children.Cast<UIElement>().First(), Children.Cast<UIElement>().Last()); } else { if (newContent != null) Children.Insert(0, newContent); transition.BeginTransition(this, Children.Cast<UIElement>().Last(), Children.Cast<UIElement>().First()); } }
public void DoTransition(object newContent, ITransition transition) { if(newContent == null) { Children.Clear(); return; } UIElement view; if(ContentTemplate != null) { var template = ContentTemplate.LoadContent(); var fe = template as FrameworkElement; if(fe != null) fe.DataContext = newContent; view = template as UIElement; } else view = newContent as UIElement; if(view == null) return; if (Children.Contains(view)) { Children.Clear(); Children.Add(view); return; } if(Children.Count > 0) { if(transition.RequiresNewContentTopmost) { Children.Add(view); transition.BeginTransition(this, Children[0], view); } else { Children.Insert(0, view); transition.BeginTransition(this, Children[1], view); } } else { Children.Add(view); TransitionEnded(transition, null, view); } }