namespace HistoryView.Controls; /// /// Interaction logic for Header.xaml /// public partial class Header : UserControl { public Header() { InitializeComponent(); TitleName.Visibility = Visibility.Collapsed; } public string Title { get { return (string)GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } } // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc... public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(Header), new PropertyMetadata(default, TitlePropertyChangedCallback)); private static void TitlePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not Header header) return; if (e.NewValue is not string title || string.IsNullOrEmpty(title)) { header.TitleName.Visibility = Visibility.Collapsed; return; } header.TitleName.Visibility = Visibility.Visible; } public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } } // Using a DependencyProperty as the backing store for CornerRadius. This enables animation, styling, binding, etc... public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Header), new PropertyMetadata(default)); public object DisplayContent { get { return (object)GetValue(DisplayContentProperty); } set { SetValue(DisplayContentProperty, value); } } // Using a DependencyProperty as the backing store for DisplayContent. This enables animation, styling, binding, etc... public static readonly DependencyProperty DisplayContentProperty = DependencyProperty.Register("DisplayContent", typeof(object), typeof(Header), new PropertyMetadata(default)); public object UserContent { get { return (object)GetValue(UserContentProperty); } set { SetValue(UserContentProperty, value); } } // Using a DependencyProperty as the backing store for UserContent. This enables animation, styling, binding, etc... public static readonly DependencyProperty UserContentProperty = DependencyProperty.Register("UserContent", typeof(object), typeof(Header), new PropertyMetadata(default)); }