I am adding rows to a data grid dynamically using a list as and item source.
However I want to disable the user for editing some of the cells of the data grid.
How can I do that in a simple way?
Attached my code:
/// <summary>
/// this class contain the data for the table in order to add the data for the table
/// </summary>
public class DataFroGrid
{
private string des;
/// <summary>
/// conatin the desction field for the data
/// </summary>
public string Description
{
get { return des; }
set { des = value; }
}
private string numberOfBytes;
/// <summary>
/// contain the number of byte for adding to the data
/// </summary>
public string NumberOfBytes
{
get { return numberOfBytes; }
set { numberOfBytes = value; }
}
private string value;
/// <summary>
/// contain the value for adding to the data
/// </summary>
public string Value
{
get { return this.value; }
set { this.value = value; }
}
public DataFroGrid ()
{
des = "";
numberOfBytes = "";
value = "";
}
}
private List<DataFroGrid> _ListForDataCommands; // a list for attached the data as a data source
public addQuestionMarkCommand(string[] description, int[] numberOfBytes ,string [] Value)
{
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; // start window in the middle of the screen
_ListForDataCommands = new List<DataFroGrid>();
res = ""; // get the result values
InitializeComponent();
eUserClosed += addQuestionMarkCommand_eUserClosed; // create an event for closing the window.
// update the item source per the data that has been received
for (int i = 0; i < description.Length; i++)
{
DataFroGrid dfg = new DataFroGrid();
dfg.Description = description[i];
dfg.NumberOfBytes = numberOfBytes[i].ToString();
dfg.Value = Value[i];
_ListForDataCommands.Add(dfg);
//want to disable editing cell per data????
}
dataGridCommand.ItemsSource = _ListForDataCommands;
}