using Muchinfo.MTPClient.Data.Model.Delivery;
using Muchinfo.MTPClient.Delivery.ViewModels;
using Muchinfo.WPF.Controls.DataGrid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 Muchinfo.MTPClient.Delivery.Views
{
///
/// NDeliveryEntructOrderView.xaml 的交互逻辑
///
public partial class NDeliveryEntructOrderView : UserControl
{
public NDeliveryEntructOrderView()
{
InitializeComponent();
}
private void MuchinfoDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataGridRow row = (DataGridRow)this.DeliveryDataGrid.ItemContainerGenerator.ContainerFromIndex(this.DeliveryDataGrid.SelectedIndex);
CheckBox rowCheck = GetChildObject(row, "DetailCheckBox");
if (rowCheck != null)
{
if (rowCheck.IsChecked == true)
{
rowCheck.IsChecked = false;
}
else
{
rowCheck.IsChecked = true;
}
}
}
public T GetChildObject(DependencyObject obj, string name) where T : FrameworkElement
{
DependencyObject child = null;
T grandChild = null;
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
{
child = VisualTreeHelper.GetChild(obj, i);
if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
{
return (T)child;
}
else
{
grandChild = GetChildObject(child, name);
if (grandChild != null)
return grandChild;
}
}
return null;
}
}
}