Header.xaml.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. namespace HistoryView.Controls;
  2. /// <summary>
  3. /// Interaction logic for Header.xaml
  4. /// </summary>
  5. public partial class Header : UserControl
  6. {
  7. public Header()
  8. {
  9. InitializeComponent();
  10. TitleName.Visibility = Visibility.Collapsed;
  11. }
  12. public string Title
  13. {
  14. get { return (string)GetValue(TitleProperty); }
  15. set { SetValue(TitleProperty, value); }
  16. }
  17. // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
  18. public static readonly DependencyProperty TitleProperty =
  19. DependencyProperty.Register("Title", typeof(string), typeof(Header), new PropertyMetadata(default, TitlePropertyChangedCallback));
  20. private static void TitlePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  21. {
  22. if (d is not Header header)
  23. return;
  24. if (e.NewValue is not string title || string.IsNullOrEmpty(title))
  25. {
  26. header.TitleName.Visibility = Visibility.Collapsed;
  27. return;
  28. }
  29. header.TitleName.Visibility = Visibility.Visible;
  30. }
  31. public CornerRadius CornerRadius
  32. {
  33. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  34. set { SetValue(CornerRadiusProperty, value); }
  35. }
  36. // Using a DependencyProperty as the backing store for CornerRadius. This enables animation, styling, binding, etc...
  37. public static readonly DependencyProperty CornerRadiusProperty =
  38. DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Header), new PropertyMetadata(default));
  39. public object DisplayContent
  40. {
  41. get { return (object)GetValue(DisplayContentProperty); }
  42. set { SetValue(DisplayContentProperty, value); }
  43. }
  44. // Using a DependencyProperty as the backing store for DisplayContent. This enables animation, styling, binding, etc...
  45. public static readonly DependencyProperty DisplayContentProperty =
  46. DependencyProperty.Register("DisplayContent", typeof(object), typeof(Header), new PropertyMetadata(default));
  47. public object UserContent
  48. {
  49. get { return (object)GetValue(UserContentProperty); }
  50. set { SetValue(UserContentProperty, value); }
  51. }
  52. // Using a DependencyProperty as the backing store for UserContent. This enables animation, styling, binding, etc...
  53. public static readonly DependencyProperty UserContentProperty =
  54. DependencyProperty.Register("UserContent", typeof(object), typeof(Header), new PropertyMetadata(default));
  55. }