using WPFluent.Extensions;
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
///
/// Extended with additional parameters like .
///
public class TextBlock : System.Windows.Controls.TextBlock
{
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty FontTypographyProperty = DependencyProperty.Register(
nameof(FontTypography),
typeof(FontTypography),
typeof(TextBlock),
new PropertyMetadata(
FontTypography.Body,
static(o, args) =>
{
((TextBlock)o).OnFontTypographyChanged((FontTypography)args.NewValue);
}));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register(
nameof(Appearance),
typeof(TextColor),
typeof(TextBlock),
new PropertyMetadata(
TextColor.Primary,
static(o, args) =>
{
((TextBlock)o).OnAppearanceChanged((TextColor)args.NewValue);
}));
public TextBlock()
{
var defaultFontTypography = (FontTypography)FontTypographyProperty.DefaultMetadata.DefaultValue;
SetResourceReference(StyleProperty, defaultFontTypography.ToResourceValue());
}
private void OnAppearanceChanged(TextColor textColor)
{ SetResourceReference(ForegroundProperty, textColor.ToResourceValue()); }
private void OnFontTypographyChanged(FontTypography newTypography)
{ SetResourceReference(StyleProperty, newTypography.ToResourceValue()); }
///
/// Gets or sets the color of the text.
///
public TextColor Appearance
{
get => (TextColor)GetValue(AppearanceProperty);
set => SetValue(AppearanceProperty, value);
}
///
/// Gets or sets the of the text.
///
public FontTypography FontTypography
{
get => (FontTypography)GetValue(FontTypographyProperty);
set => SetValue(FontTypographyProperty, value);
}
}