using System.Windows.Controls; using System.Windows; namespace HMI.UI.DpUtil { public class DataGridColumnHelper { public static object GetBindHeader(DataGridColumn obj) { return obj.GetValue(BindHeaderProperty); } public static void SetBindHeader(DataGridColumn obj, object value) { obj.SetValue(BindHeaderProperty, value); } public static readonly DependencyProperty BindHeaderProperty = DependencyProperty.Register("BindHeader", typeof(object), typeof(DataGridColumn), new PropertyMetadata(null, OnBindHeaderChanged)); private static void OnBindHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.Property != BindHeaderProperty) return; if (!(d is DataGridColumn column)) return; column.Header = e.NewValue; } } }