1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace InABox.DynamicGrid
- {
- /// <summary>
- /// Interaction logic for FormHeader.xaml
- /// </summary>
- public partial class FormHeader : UserControl
- {
- public delegate void CollapsedChangedEvent(FormHeader header, bool collapsed);
- public static readonly DependencyProperty HeaderTextProperty = DependencyProperty.Register("HeaderText", typeof(string), typeof(FormHeader));
- public static readonly DependencyProperty CollapsedProperty = DependencyProperty.Register(
- "Collapsed", typeof(bool), typeof(FormHeader),
- new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnCollapsedChanged)));
- public static readonly DependencyProperty TextDecorationsProperty = DependencyProperty.Register("TextDecorations", typeof(TextDecorationCollection), typeof(FormHeader));
- public string HeaderText
- {
- get => GetValue(HeaderTextProperty).ToString() ?? "";
- set => SetValue(HeaderTextProperty, value);
- }
- public bool Collapsed
- {
- get => (bool)GetValue(CollapsedProperty);
- set => SetValue(CollapsedProperty, value);
- }
- public TextDecorationCollection TextDecorations
- {
- get => TextBlock.TextDecorations;
- set => TextBlock.TextDecorations = value;
- }
- public event CollapsedChangedEvent? CollapsedChanged;
- public FormHeader()
- {
- InitializeComponent();
- }
- private static void OnCollapsedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var header = (FormHeader)d;
- var collapsed = (bool)e.NewValue;
- header.CollapsedChanged?.Invoke(header, collapsed);
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- Collapsed = !Collapsed;
- }
- }
- }
|