I have an an DataGrid in which I load Data from an ObservableCollection and each row has an CheckBox so that I can have a list of checked Rows. Now I wanted to add an new Column to the DataGrid which is an ComboBox and in the ComboBox is a list with Checkboxen. I want for each row that when I check one Row and then when I check other Items from the ComboBox that I can combine the selected row and the selected values from my ComboBox.
The problem is that if I check one Row of the Combobox item it will check for every other ComboBox that appears in the DataGrid.
I want only to check the value of the combobox for one row and combine it with the Value of the checked row of the datagrid.
Here is my Code of my DataGrid:
my itemtemplate of my ComboBox:
my "bischenanders" collection (sry for that bad name I will fix that in the future)
my outputColumns class:
public class OutputColumns
{
public string Spaltenname{ get; set; }
public bool IsChecked { get; set; }
public bool cmbIsChecked { get; set; }
}
thats the way I read the selected Items for the rows and for the Combobox rows
public List GetSelectedItems()
{
var selectedItems = new List();
foreach (OutputColumns item in View.bischenanders)
{
try
{
if (item.IsChecked)
{
selectedItems.Add(item);
}
}
catch
{
}
}
return selectedItems;
}
public List cmbGetSelectedItems()
{
var selectedItems = new List();
foreach (OutputColumns item in View.bischenanders)
{
try
{
if (item.cmbIsChecked)
{
selectedItems.Add(item);
}
}
catch
{
}
}
return selectedItems;
}
ut when I check in one CombobBox every combobox in the DataGrid has the same checked Values
It looks like that every time I open a new ComboBox he getting the data from the class and then there will the programm find a version where it is checked, because ComboBoxs I already have open get there own checked values, only the new ones getting the checked one that are checked in the previous checkbox.
Thanks for help!
Rajeesh MenothPosted Jan 7, 2023, 6:57 AM
Hi,
Look like the selected values still persist in the combo box so probably after selecting the combo box value you should clear the property that you have used. Then the next select you will get the updated value.
Reference:
https://www.codeproject.com/Questions/5296329/Three-combobox-has-same-values-when-combobox1-sele