From 453839e7637e23356d0b863af2628e2b46a3ae7c Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Wed, 20 Nov 2019 00:18:11 +0800
Subject: [PATCH] close #234
now you can customize dot by PageButtonStyle property @jingsong-liu
---
.../Controls/Block/FloatingBlock.cs | 11 +++-
.../Controls/Other/Carousel.cs | 59 ++++++++-----------
.../Controls/Slider/PreviewSlider.cs | 18 ++++--
.../Themes/Styles/Carousel.xaml | 31 +++++++++-
4 files changed, 78 insertions(+), 41 deletions(-)
diff --git a/src/Shared/HandyControl_Shared/Controls/Block/FloatingBlock.cs b/src/Shared/HandyControl_Shared/Controls/Block/FloatingBlock.cs
index f838f2bf..3a7287bb 100644
--- a/src/Shared/HandyControl_Shared/Controls/Block/FloatingBlock.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Block/FloatingBlock.cs
@@ -173,9 +173,16 @@ namespace HandyControl.Controls
storyboard.Completed += (s, e) =>
{
var layer = AdornerLayer.GetAdornerLayer(element);
- if (layer == null) return;
+ if (layer != null)
+ {
+ layer.Remove(adorner);
+ }
+ else if (adorner.Parent is AdornerLayer parent)
+ {
+ parent.Remove(adorner);
+ }
+
adorner.Child = null;
- layer.Remove(adorner);
};
storyboard.Children.Add(animationX);
storyboard.Children.Add(animationY);
diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Carousel.cs b/src/Shared/HandyControl_Shared/Controls/Other/Carousel.cs
index 3492f38b..61cc89ad 100644
--- a/src/Shared/HandyControl_Shared/Controls/Other/Carousel.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Other/Carousel.cs
@@ -8,7 +8,6 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Markup;
-using System.Windows.Media;
using System.Windows.Threading;
using HandyControl.Data;
using HandyControl.Interactivity;
@@ -42,7 +41,7 @@ namespace HandyControl.Controls
private int _pageIndex = -1;
- private Button _selectedButton;
+ private RadioButton _selectedButton;
private DispatcherTimer _updateTimer;
@@ -104,6 +103,15 @@ namespace HandyControl.Controls
set => SetValue(IsCenterProperty, value);
}
+ public static readonly DependencyProperty PageButtonStyleProperty = DependencyProperty.Register(
+ "PageButtonStyle", typeof(Style), typeof(Carousel), new PropertyMetadata(default(Style)));
+
+ public Style PageButtonStyle
+ {
+ get => (Style) GetValue(PageButtonStyleProperty);
+ set => SetValue(PageButtonStyleProperty, value);
+ }
+
public Carousel()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, ButtonPrev_OnClick));
@@ -210,15 +218,21 @@ namespace HandyControl.Controls
_panelPage.Children.Clear();
for (var i = 0; i < count; i++)
{
- _panelPage.Children.Add(CreatePateButton());
+ _panelPage.Children.Add(new RadioButton
+ {
+ Style = PageButtonStyle
+ });
}
if (index == -1 && count > 0) index = 0;
if (index >= 0 && index < count)
{
- var button = _panelPage.Children[index];
- button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button));
- UpdateItemsPosition();
+ if (_panelPage.Children[index] is RadioButton button)
+ {
+ button.IsChecked = true;
+ button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button));
+ UpdateItemsPosition();
+ }
}
}
@@ -251,40 +265,17 @@ namespace HandyControl.Controls
UpdateItemsPosition();
}
- ///
- /// 创建页按钮
- ///
- ///
- private Button CreatePateButton()
- {
- var button = new Button
- {
- Style = ResourceHelper.GetResource
+
+