зеркало из https://github.com/AvaloniaUI/Avalonia.git
Make carousel page transition changable in catalog.
This commit is contained in:
Родитель
c49201b8cb
Коммит
fd36871332
|
@ -22,7 +22,7 @@
|
|||
|
||||
<StackPanel Orientation="Horizontal" Gap="4">
|
||||
<TextBlock VerticalAlignment="Center">Transition</TextBlock>
|
||||
<DropDown SelectedIndex="0" VerticalAlignment="Center">
|
||||
<DropDown Name="transition" SelectedIndex="1" VerticalAlignment="Center">
|
||||
<ListBoxItem>None</ListBoxItem>
|
||||
<ListBoxItem>Slide</ListBoxItem>
|
||||
<ListBoxItem>Crossfade</ListBoxItem>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Perspex.Controls;
|
||||
using System;
|
||||
using Perspex.Animation;
|
||||
using Perspex.Controls;
|
||||
using Perspex.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
|
@ -8,12 +10,14 @@ namespace ControlCatalog.Pages
|
|||
private Carousel _carousel;
|
||||
private Button _left;
|
||||
private Button _right;
|
||||
private DropDown _transition;
|
||||
|
||||
public CarouselPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
_left.Click += (s, e) => _carousel.Previous();
|
||||
_right.Click += (s, e) => _carousel.Next();
|
||||
_transition.SelectionChanged += TransitionChanged;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
@ -22,6 +26,23 @@ namespace ControlCatalog.Pages
|
|||
_carousel = this.FindControl<Carousel>("carousel");
|
||||
_left = this.FindControl<Button>("left");
|
||||
_right = this.FindControl<Button>("right");
|
||||
_transition = this.FindControl<DropDown>("transition");
|
||||
}
|
||||
|
||||
private void TransitionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
switch (_transition.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
_carousel.Transition = null;
|
||||
break;
|
||||
case 1:
|
||||
_carousel.Transition = new PageSlide(TimeSpan.FromSeconds(0.25));
|
||||
break;
|
||||
case 2:
|
||||
_carousel.Transition = new CrossFade(TimeSpan.FromSeconds(0.25));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
<Compile Include="Primitives\IScrollable.cs" />
|
||||
<Compile Include="Primitives\TabStripItem.cs" />
|
||||
<Compile Include="Primitives\TemplateAppliedEventArgs.cs" />
|
||||
<Compile Include="SelectionChangedEventArgs.cs" />
|
||||
<Compile Include="SelectionMode.cs" />
|
||||
<Compile Include="Separator.cs" />
|
||||
<Compile Include="SystemDialog.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче