/// <summary> /// 创建商品控件 /// </summary> private void CreateProduct(List <GoodsModel> products) { panelProduct.Children.Clear(); int index = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { if (index < products.Count) { GoodsButton productControl = new GoodsButton() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = System.Windows.VerticalAlignment.Stretch, Margin = new Thickness(5) }; Grid.SetRow(productControl, i); Grid.SetColumn(productControl, j); panelProduct.Children.Add(productControl); productControl.MouseLeftButtonUp += (GoodsWayChecked); productControl.SetCurrentGoods(products[index]); productControl.SetOneText(products[index].McdCode); productControl.SetSecondText(products[index].McdName); } index++; } } }
/// <summary> /// 产品选中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GoodsWayChecked(object sender, MouseButtonEventArgs e) { var goodsWay = (sender as GoodsButton); if (goodsWay == currentGoods) { return; } if (goodsWay != null) { if (currentGoods != null) { currentGoods.ToNormal(); } goodsWay.ToCheck(); currentGoods = goodsWay; btnOk.IsEnabled = true; } }
/// <summary> /// 产品选中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GoodsWayChecked(object sender, MouseButtonEventArgs e) { var goodsWay = (sender as GoodsButton); if (goodsWay == m_CurrentGoods) { return; } if (goodsWay != null) { if (m_CurrentGoods != null) { m_CurrentGoods.ToNormal(); } goodsWay.ToCheck(); m_CurrentGoods = goodsWay; btnView.IsEnabled = btnDelete.IsEnabled = true; } }