Skip to content

Commit 15ddfdc

Browse files
committed
Add CarouselView
1 parent 93c62db commit 15ddfdc

File tree

13 files changed

+1156
-0
lines changed

13 files changed

+1156
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Install-Package DevWinUI
135135
## 🔥 DevWinUI.Controls 🔥
136136
### ⚡ What’s Inside? ⚡
137137

138+
- ✨ CarouselView
138139
- ✨ EasyCarouselPanel
139140
- ✨ Stars
140141
- ✨ BannerView
@@ -316,6 +317,9 @@ Install-Package DevWinUI.ContextMenu
316317

317318
## 🕰️ History 🕰️
318319

320+
### CarouselView
321+
![CarouselView](https://raw.githubusercontent.com/ghost1372/DevWinUI-Resources/refs/heads/main/DevWinUI-Docs/CarouselView.gif)
322+
319323
### EasyCarouselPanel
320324
![EasyCarouselPanel](https://raw.githubusercontent.com/ghost1372/DevWinUI-Resources/refs/heads/main/DevWinUI-Docs/EasyCarouselPanel.gif)
321325

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
namespace DevWinUI;
2+
3+
public sealed partial class CarouselView
4+
{
5+
public int SelectedIndex
6+
{
7+
get { return (int)GetValue(SelectedIndexProperty); }
8+
set { SetValue(SelectedIndexProperty, value); }
9+
}
10+
11+
public static readonly DependencyProperty SelectedIndexProperty =
12+
DependencyProperty.Register(nameof(SelectedIndex), typeof(int), typeof(CarouselView), new PropertyMetadata(-1, (s, e) =>{}));
13+
public double ItemWidth
14+
{
15+
get { return (double)GetValue(ItemWidthProperty); }
16+
set { SetValue(ItemWidthProperty, value); }
17+
}
18+
19+
public static readonly DependencyProperty ItemWidthProperty =
20+
DependencyProperty.Register(nameof(ItemWidth), typeof(double), typeof(CarouselView), new PropertyMetadata(300.00d));
21+
22+
public List<ICarouselViewItemSource> ItemImageSource
23+
{
24+
get { return (List<ICarouselViewItemSource>)GetValue(ItemImageSourceProperty); }
25+
set
26+
{
27+
SetValue(ItemImageSourceProperty, value);
28+
this.SetItemsImageSource();
29+
}
30+
}
31+
32+
public static readonly DependencyProperty ItemImageSourceProperty =
33+
DependencyProperty.Register(nameof(ItemImageSource), typeof(List<ICarouselViewItemSource>), typeof(CarouselView), new PropertyMetadata(null, (s, e) =>
34+
{
35+
var carousel = s as CarouselView;
36+
if (carousel != null)
37+
{
38+
carousel.SetItemsImageSource();
39+
}
40+
}));
41+
public bool IsAutoSwitchEnabled
42+
{
43+
get { return (bool)GetValue(IsAutoSwitchEnableProperty); }
44+
set { SetValue(IsAutoSwitchEnableProperty, value); }
45+
}
46+
47+
public static readonly DependencyProperty IsAutoSwitchEnableProperty =
48+
DependencyProperty.Register(nameof(IsAutoSwitchEnabled), typeof(bool), typeof(CarouselView), new PropertyMetadata(true, (s, e) =>
49+
{
50+
if (e.NewValue != e.OldValue)
51+
{
52+
if ((bool)e.NewValue)
53+
{
54+
(s as CarouselView)._dispatcherTimer.Start();
55+
}
56+
else
57+
{
58+
(s as CarouselView)._dispatcherTimer.Stop();
59+
}
60+
}
61+
}));
62+
63+
public TimeSpan AutoSwitchInterval
64+
{
65+
get { return (TimeSpan)GetValue(AutoSwitchIntervalProperty); }
66+
set { SetValue(AutoSwitchIntervalProperty, value); }
67+
}
68+
69+
public static readonly DependencyProperty AutoSwitchIntervalProperty =
70+
DependencyProperty.Register(nameof(AutoSwitchInterval), typeof(TimeSpan), typeof(CarouselView), new PropertyMetadata(new TimeSpan(0, 0, 7), (s, e) =>
71+
{
72+
if (e.NewValue != e.OldValue)
73+
{
74+
(s as CarouselView)._dispatcherTimer.Interval = (TimeSpan)e.NewValue;
75+
(s as CarouselView)._dispatcherTimer.Start();
76+
}
77+
}));
78+
}

0 commit comments

Comments
 (0)