优化更新代码,添加界面功能并整合
This commit is contained in:
53
WPFluent/Controls/Card/Card.cs
Normal file
53
WPFluent/Controls/Card/Card.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace WPFluent.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Simple Card with content and <see cref="Footer"/>.
|
||||
/// </summary>
|
||||
public class Card : System.Windows.Controls.ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Footer"/> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FooterProperty = DependencyProperty.Register(
|
||||
nameof(Footer),
|
||||
typeof(object),
|
||||
typeof(Card),
|
||||
new PropertyMetadata(null, OnFooterChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="HasFooter"/> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HasFooterProperty = DependencyProperty.Register(
|
||||
nameof(HasFooter),
|
||||
typeof(bool),
|
||||
typeof(Card),
|
||||
new PropertyMetadata(false));
|
||||
|
||||
private static void OnFooterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if(d is not Card control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
control.SetValue(HasFooterProperty, control.Footer != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets additional content displayed at the bottom.
|
||||
/// </summary>
|
||||
public object? Footer { get => GetValue(FooterProperty); set => SetValue(FooterProperty, value); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="Card"/> has a <see cref="Footer"/>.
|
||||
/// </summary>
|
||||
public bool HasFooter
|
||||
{
|
||||
get => (bool)GetValue(HasFooterProperty);
|
||||
internal set => SetValue(HasFooterProperty, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user