NDeliveryEntructOrderView.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Muchinfo.MTPClient.Data.Model.Delivery;
  2. using Muchinfo.MTPClient.Delivery.ViewModels;
  3. using Muchinfo.WPF.Controls.DataGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace Muchinfo.MTPClient.Delivery.Views
  18. {
  19. /// <summary>
  20. /// NDeliveryEntructOrderView.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class NDeliveryEntructOrderView : UserControl
  23. {
  24. public NDeliveryEntructOrderView()
  25. {
  26. InitializeComponent();
  27. }
  28. private void MuchinfoDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
  29. {
  30. DataGridRow row = (DataGridRow)this.DeliveryDataGrid.ItemContainerGenerator.ContainerFromIndex(this.DeliveryDataGrid.SelectedIndex);
  31. CheckBox rowCheck = GetChildObject<CheckBox>(row, "DetailCheckBox");
  32. if (rowCheck != null)
  33. {
  34. if (rowCheck.IsChecked == true)
  35. {
  36. rowCheck.IsChecked = false;
  37. }
  38. else
  39. {
  40. rowCheck.IsChecked = true;
  41. }
  42. }
  43. }
  44. public T GetChildObject<T>(DependencyObject obj, string name) where T : FrameworkElement
  45. {
  46. DependencyObject child = null;
  47. T grandChild = null;
  48. for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
  49. {
  50. child = VisualTreeHelper.GetChild(obj, i);
  51. if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
  52. {
  53. return (T)child;
  54. }
  55. else
  56. {
  57. grandChild = GetChildObject<T>(child, name);
  58. if (grandChild != null)
  59. return grandChild;
  60. }
  61. }
  62. return null;
  63. }
  64. }
  65. }