|
|
@ -33,12 +33,13 @@ namespace Avalonia.Controls.Presenters |
|
|
(o, v) => o.SelectedIndex = v); |
|
|
(o, v) => o.SelectedIndex = v); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Defines the <see cref="Transition"/> property.
|
|
|
/// Defines the <see cref="PageTransition"/> property.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static readonly StyledProperty<IPageTransition> TransitionProperty = |
|
|
public static readonly StyledProperty<IPageTransition> PageTransitionProperty = |
|
|
Carousel.TransitionProperty.AddOwner<CarouselPresenter>(); |
|
|
Carousel.PageTransitionProperty.AddOwner<CarouselPresenter>(); |
|
|
|
|
|
|
|
|
private int _selectedIndex = -1; |
|
|
private int _selectedIndex = -1; |
|
|
|
|
|
private Task _current; |
|
|
private Task _currentTransition; |
|
|
private Task _currentTransition; |
|
|
private int _queuedTransitionIndex = -1; |
|
|
private int _queuedTransitionIndex = -1; |
|
|
|
|
|
|
|
|
@ -88,10 +89,10 @@ namespace Avalonia.Controls.Presenters |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets or sets a transition to use when switching pages.
|
|
|
/// Gets or sets a transition to use when switching pages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public IPageTransition Transition |
|
|
public IPageTransition PageTransition |
|
|
{ |
|
|
{ |
|
|
get { return GetValue(TransitionProperty); } |
|
|
get { return GetValue(PageTransitionProperty); } |
|
|
set { SetValue(TransitionProperty, value); } |
|
|
set { SetValue(PageTransitionProperty, value); } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
@ -121,7 +122,7 @@ namespace Avalonia.Controls.Presenters |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Moves to the selected page, animating if a <see cref="Transition"/> is set.
|
|
|
/// Moves to the selected page, animating if a <see cref="PageTransition"/> is set.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="fromIndex">The index of the old page.</param>
|
|
|
/// <param name="fromIndex">The index of the old page.</param>
|
|
|
/// <param name="toIndex">The index of the new page.</param>
|
|
|
/// <param name="toIndex">The index of the new page.</param>
|
|
|
@ -144,9 +145,9 @@ namespace Avalonia.Controls.Presenters |
|
|
to = GetOrCreateContainer(toIndex); |
|
|
to = GetOrCreateContainer(toIndex); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (Transition != null && (from != null || to != null)) |
|
|
if (PageTransition != null && (from != null || to != null)) |
|
|
{ |
|
|
{ |
|
|
await Transition.Start((Visual)from, (Visual)to, fromIndex < toIndex); |
|
|
await PageTransition.Start((Visual)from, (Visual)to, fromIndex < toIndex); |
|
|
} |
|
|
} |
|
|
else if (to != null) |
|
|
else if (to != null) |
|
|
{ |
|
|
{ |
|
|
|