如何在C#WPF中选择listview的特定行?(未选择行)

如何在C#WPF中选择listview的特定行?(未选择行),listview,listviewitem,dynamic-list,wpf-listview,Listview,Listviewitem,Dynamic List,Wpf Listview,我正在做一个销售点计划,基本上有一个列表视图和产品入口。当用户输入相同的产品时,此程序应增加列表中现有产品的数量,而不是创建新的整行 所以,我的问题是如何在WPF的ListView中动态添加项。我的意思是,我想选择一个listview的特定行来获取它的特定单元格。但是我不想得到选中的行。只是一行而已 让我将其描述为一个矩阵:lvProduct[0][2]。这应该给我第一行的第二个单元格。如何在C#WPF中应用它 我的代码如下: private void btnProductAdd_Cli

我正在做一个销售点计划,基本上有一个列表视图和产品入口。当用户输入相同的产品时,此程序应增加列表中现有产品的数量,而不是创建新的整行

所以,我的问题是如何在WPF的ListView中动态添加项。我的意思是,我想选择一个listview的特定行来获取它的特定单元格。但是我不想得到选中的行。只是一行而已

让我将其描述为一个矩阵:lvProduct[0][2]。这应该给我第一行的第二个单元格。如何在C#WPF中应用它

我的代码如下:

    private void btnProductAdd_Click(object sender, RoutedEventArgs e)
    {
        bool addNewProductLine = true;
        decimal totalSalePrice = Convert.ToDecimal(txtProductPrice.Text) * Convert.ToInt32(txtProductAmount.Text);



        for (int i = 0; i < lvProducts.Items.Count; i++)
        {
            ProductBLL product = lvProducts.Items.GetItemAt(i) as ProductBLL;

            if (product.BarcodeRetail== txtProductBarcode.Text)//If there is already the same item on the list, then confirm to add them together or not.
            {
                if (MessageBox.Show("There is already the same item in the list. Would you like to sum them?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    product.Amount +=Convert.ToInt32(txtProductAmount.Text);
                    addNewProductLine = false;
                    break;
                }
            }
        }

        List<ProductBLL> items = new List<ProductBLL>();
        items.Add(new ProductBLL() { BarcodeRetail=txtProductBarcode.Text, Name = txtProductName.Text, UnitRetail = Convert.ToInt32(cboProductUnit.SelectedIndex), SalePrice = Convert.ToDecimal(txtProductPrice.Text), Amount = Convert.ToInt32(txtProductAmount.Text), TotalSalePrice =  totalSalePrice});
        //lvProducts.ItemsSource = items; This code renew the listview completely. That means, it erases old datas and writes the new ones.

        if (addNewProductLine == true)
        {
            lvProducts.Items.Add(items);
        }

        ClearProductEntranceTextBox();

        //items[0].BarcodeRetail = "EXAMPLECODE"; This code can change the 0th row's data on the column called BarcodeRetail.
    }
private void btnProductAdd\u单击(对象发送方,路由目标)
{
bool addNewProductLine=true;
十进制totalSalePrice=Convert.ToDecimal(txtProductPrice.Text)*Convert.ToInt32(txtProductAmount.Text);
对于(int i=0;i
不幸的是,此代码不起作用:/

提前感谢大家