2025-05-05 17:04:06 +08:00
|
|
|
|
namespace WPFluent.Controls;
|
2025-02-10 20:53:40 +08:00
|
|
|
|
|
|
|
|
|
|
/// <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)
|
|
|
|
|
|
{
|
2025-04-24 20:56:44 +08:00
|
|
|
|
if (d is not Card control)
|
2025-02-10 20:53:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|