So I have a dynamic RadGridView using MVVM and Caliburn Micro. This means that I add Columns programmatically to the control. basically like this:
for (int i = 0; i < length; i++)
{
Binding b = new Binding(string.Format("Collection[{0}].ValueIWant", i));
binding.StringFormat = "{0:0.##}";
GridViewDataColumn column = new GridViewDataColumn()
{
Header = HeaderFor(i),
DataMemberBinding = b,
DataType = typeof(double?)
};
Control.columns.Add(column);
}
Now I need to add new lines that show the percentage between line 1 and 2
, 2 and 3
and so on.
I've managed to do that but I'm not sure how I would manage to change the String.format specifically for those cells instead of the whole column.
CellTemplateSelector came to mind but I'm not sure that is a good idea as this might mean I have to set the binding again, not knowing the value of i
and such. Also I only want to change the string.format on the binding.
As I'm manipulating the number as a double (0,5 is 50%, 50 is 5000%) I guess I have to mask the input as well. not sure if String.Format does that for me as well or if I should use RadMaskedInput