HistoryControl.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using FWindSoft.Wpf.History;
  9. namespace FWindSoft.Wpf.Controls
  10. {
  11. public class HistoryControl
  12. {
  13. public static readonly DependencyProperty IsSaveProperty = DependencyProperty.RegisterAttached("IsSave",
  14. typeof(bool), typeof(HistoryControl), new PropertyMetadata(false, OnPropertyChanged));
  15. public static readonly DependencyProperty ValueAdapterProperty = DependencyProperty.RegisterAttached("ValueAdapter",
  16. typeof(ElementValueProvider), typeof(HistoryControl), new PropertyMetadata(null, OnPropertyChanged));
  17. public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  18. {
  19. //TextBox textBox = d as TextBox;
  20. //if (textBox == null)
  21. // return;
  22. }
  23. [AttachedPropertyBrowsableForType(typeof(Control))]
  24. public static ElementValueProvider GetValueAdapter(DependencyObject obj)
  25. {
  26. return obj.GetValue(ValueAdapterProperty) as ElementValueProvider;
  27. }
  28. [AttachedPropertyBrowsableForType(typeof(Control))]
  29. public static void SetValueAdapter(DependencyObject obj, string value)
  30. {
  31. obj.SetValue(ValueAdapterProperty, value);
  32. }
  33. [AttachedPropertyBrowsableForType(typeof(Control))]
  34. public static bool GetIsSave(DependencyObject obj)
  35. {
  36. return (bool)obj.GetValue(IsSaveProperty);
  37. }
  38. [AttachedPropertyBrowsableForType(typeof(Control))]
  39. public static void SetIsSave(DependencyObject obj, bool value)
  40. {
  41. obj.SetValue(IsSaveProperty, value);
  42. }
  43. }
  44. }