using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
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.Shapes;
using 智慧物流软件系统.ViewModels;
using DataGrid = System.Windows.Controls.DataGrid;

namespace 智慧物流软件系统
{
    /// <summary>
    /// InInventoryView.xaml 的交互逻辑
    /// </summary>
    public partial class OutInventoryDocumentView : UserControlBase
    {
        public OutInventoryDocumentViewModel viewModel = new OutInventoryDocumentViewModel();
        public OutInventoryDocumentView()
        {
            InitializeComponent();
            this.DataContext = viewModel;
        }
        private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                if (viewModel.SelectedataGridItem != null)
                {
                    viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected;
                    this.dg.UnselectAllCells();//取消选中 避免手动点击check选项时反选失败 和重新点击该项时反选失败
                }
            }
            catch
            {
            }
        }
        private void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Pager)
            {
                if (e.Item.Cells[1].Text.Length > 20)
                {
                    e.Item.Cells[1].Text = e.Item.Cells[1].Text.Substring(0, 20) + "...";
                }
                if (e.Item.Cells[2].Text.Length > 20)
                {
                    e.Item.Cells[2].Text = e.Item.Cells[2].Text.Substring(0, 20) + "...";
                }
            }
        }
    }
}
