WinChild.xaml.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using FWindSoft.Wpf;
  2. using FWindSoft.Wpf.Controls;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.ComponentModel;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. using System.Windows.Threading;
  21. namespace Test.ChildWindow
  22. {
  23. /// <summary>
  24. /// WinChild.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class WinChild : NChildWindow
  27. {
  28. public WinChild()
  29. {
  30. InitializeComponent();
  31. // InitData();
  32. this.DataContext = this;
  33. this.SizeChanged += WinChild_SizeChanged;
  34. }
  35. protected override void LoadData(LoadParameter parameter)
  36. {
  37. InitData();
  38. }
  39. private void WinChild_SizeChanged(object sender, SizeChangedEventArgs e)
  40. {
  41. var cc = e.NewSize;
  42. var old = e.PreviousSize;
  43. if (cc.Height < old.Height || cc.Width < old.Width)
  44. {
  45. // DataGrid.Width = 100;
  46. //DataGrid.UpdateLayout();
  47. //Trace.Write(Border1.ActualWidth);
  48. //(DataGrid.Parent as UIElement).onre.UpdateLayout();
  49. }
  50. }
  51. private ObservableCollection<string> m_EqNames;
  52. /// <summary>
  53. /// 设备名称
  54. /// </summary>
  55. public ObservableCollection<string> EqNames
  56. {
  57. get { return this.m_EqNames; }
  58. set
  59. {
  60. this.m_EqNames = value;
  61. RaiseChanged(nameof(this.EqNames));
  62. }
  63. }
  64. private void InitData()
  65. {
  66. EqNames = new ObservableCollection<string>();
  67. for (int i = 0; i < 100; i++)
  68. {
  69. EqNames.Add(i.ToString());
  70. }
  71. }
  72. }
  73. #region 通知信息
  74. public partial class WinChild : INotifyPropertyChanged
  75. {
  76. public event PropertyChangedEventHandler PropertyChanged;
  77. /// <summary>
  78. /// 提交变更
  79. /// </summary>
  80. /// <param name="propertyName">变更属性名称</param>
  81. protected void RaiseChanged(String propertyName = "")
  82. {
  83. if (PropertyChanged != null)
  84. {
  85. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  86. }
  87. }
  88. //protected void SetPropertyValue<T>(ref T old, T value, [CallerMemberName] string propertyName = "")
  89. //{
  90. // old = value;
  91. // RaiseChanged(propertyName);
  92. //}
  93. }
  94. #endregion
  95. }