整理
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
namespace NeumUI.Controls;
|
||||
namespace NeoUI.Controls;
|
||||
|
||||
using System.Windows;
|
||||
|
||||
using ContentControlBase = System.Windows.Controls.ContentControl;
|
||||
|
||||
/// <summary>
|
||||
/// A spinner for displaying loading state of a page or a section.
|
||||
/// </summary>
|
||||
[TemplateVisualState(Name = "Spun", GroupName = "SpinStates")]
|
||||
[TemplateVisualState(Name = "Unspun", GroupName = "SpinStates")]
|
||||
public class Spin : ContentControlBase
|
||||
public class Spin : ContentControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置指示器属性的依赖属性。此属性用于定义旋转控件中使用的指示器元素。
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IndicatorProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Indicator),
|
||||
@@ -20,7 +23,7 @@ public class Spin : ContentControlBase
|
||||
new PropertyMetadata(null, OnSpinningChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets element of the spinning indicator.
|
||||
/// 获取或设置指示器元素。
|
||||
/// </summary>
|
||||
public UIElement Indicator
|
||||
{
|
||||
@@ -28,6 +31,9 @@ public class Spin : ContentControlBase
|
||||
set => SetValue(IndicatorProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个布尔值,指示旋转控件是否处于旋转状态。
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SpinningProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Spinning),
|
||||
@@ -36,23 +42,26 @@ public class Spin : ContentControlBase
|
||||
new PropertyMetadata(true, OnSpinningChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets whether spin is spinning.
|
||||
/// 获取或设置是否正在旋转。
|
||||
/// </summary>
|
||||
public bool Spinning { get => (bool)GetValue(SpinningProperty);
|
||||
set => SetValue(SpinningProperty, value);
|
||||
}
|
||||
|
||||
private static void OnSpinningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{ (d as Spin).GoToSpinState(); }
|
||||
{ (d as Spin)?.GoToSpinState(); }
|
||||
|
||||
private void GoToSpinState()
|
||||
{ VisualStateManager.GoToState(this, Spinning && null == Indicator ? "Spun" : "Unspun", true); }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置提示文本。
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TipProperty =
|
||||
DependencyProperty.Register(nameof(Tip), typeof(string), typeof(Spin), new PropertyMetadata(string.Empty));
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets customize description content when spin has children.
|
||||
/// 获取或设置提示文本。
|
||||
/// </summary>
|
||||
public string Tip { get => (string)GetValue(TipProperty);
|
||||
set => SetValue(TipProperty, value);
|
||||
@@ -65,6 +74,8 @@ public class Spin : ContentControlBase
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
Reference in New Issue
Block a user