I am trying to build a DataMatrix in WPF which needs to have row and column headers, dynamically generated rows and columns and commands linked to each cell. Due to this, I am unable to use a DataGrid. There are a few solutions like Josh Smith's Data Matrix and this. I am leaning towards the former as I feel I might be able to achieve what I want more elegantly with that.
Unlike his example(Demo1), I don't know the names or the number of rows/columns before hand and am stuck in generating a KeyValuePair for the dictionary. Below is some pseudocode comparing his implementation to mine. I would appreciate if someone pointed me in the right direction. His code
class Dataclass:
{
string columnname;
int row1data;
int row2data;
}
class MatrixClass: MatrixBase<string DataClass>
{
Dictionary<string Callback> rowvaluemap;
delegate object Callback(Dataclass data);
AddMappings()
{
rowvaluemap.Add("row1name", data=>data.row1data.ToString);
}
}
My implementation ??(code)
indicates the part I'm unsure about
class MyDataclass:
{
string columnname;
string[] rownames;
int[] rowdata;
}
class MyMatrixClass: MatrixBase<string MyDataClass>
{
Dictionary<??(Callback1), ??(Callback2)> rowvaluemap;
delegate object Callback(MyDataclass data);
delegate object Callback2(MyDataclass data);
AddMappings()
{
rowvaluemap.Add(??(data=>data.rownames.ToString), ??(data=>data.rowdata.ToString));
}
}
I realize that doing it this way would most likely give me one IEnumerable key & one IEnumerable Value, but I'm completely lost on this one.I would appreciate your help or any alternative suggestions to achieve my target. Thanks