功能更新
This commit is contained in:
76
Melskin/Controls/Card.xaml.cs
Normal file
76
Melskin/Controls/Card.xaml.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Melskin.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Card 类继承自 ContentControl,用于创建具有圆角和光照效果的卡片边框。此控件可以用来装饰应用程序中的内容区域,使其外观更加美观。
|
||||
/// 通过设置 CornerRadius 属性,您可以控制卡片四角的圆滑程度;利用 LightSize 属性调节光照效果的大小;
|
||||
/// 同时,ShaderEnabled 属性允许您启用或禁用阴影效果以增强视觉体验。
|
||||
/// </summary>
|
||||
public class Card : ContentControl
|
||||
{
|
||||
static Card()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Card),
|
||||
new FrameworkPropertyMetadata(typeof(Card)));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置或获取卡片四角的圆角半径,该属性控制卡片边框的圆滑程度。
|
||||
/// </summary>
|
||||
[Category("自定义")]
|
||||
[Description("设置卡片圆角半径")]
|
||||
public CornerRadius CornerRadius
|
||||
{
|
||||
get => (CornerRadius)GetValue(CornerRadiusProperty);
|
||||
set => SetValue(CornerRadiusProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 表示 Card 控件圆角半径的依赖属性。此属性用于控制卡片四角的圆滑程度。
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CornerRadiusProperty =
|
||||
DependencyProperty.Register(nameof(CornerRadius),
|
||||
typeof(CornerRadius), typeof(Card),
|
||||
new PropertyMetadata(new CornerRadius(4)));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置或获取光照效果的尺寸,该属性控制卡片周围光照效果的大小。
|
||||
/// </summary>
|
||||
[Category("自定义")]
|
||||
[Description("设置光的尺寸")]
|
||||
public double LightSize
|
||||
{
|
||||
get => (double)GetValue(LightSizeProperty);
|
||||
set => SetValue(LightSizeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置光照效果的尺寸
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LightSizeProperty =
|
||||
DependencyProperty.Register(nameof(LightSize),
|
||||
typeof(double), typeof(Card),
|
||||
new PropertyMetadata(200.0));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enable or disable the border effect
|
||||
/// </summary>
|
||||
public bool ShaderEnabled
|
||||
{
|
||||
get => (bool)GetValue(ShaderEnabledProperty);
|
||||
set => SetValue(ShaderEnabledProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示是否启用卡片的阴影效果。启用阴影效果可以增强控件的视觉层次感和美观度。
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShaderEnabledProperty =
|
||||
DependencyProperty.Register(nameof(ShaderEnabled),
|
||||
typeof(bool), typeof(Card),
|
||||
new PropertyMetadata(true));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user