Hello,
I am manually adding UnboundField instances to XamDataGrid.FieldLayouts. These fields are bound to something whose actual type is bool. However, I'm setting UnboundField.DataType to typeof(string). I do this because I do not what checkboxes to appear in the grid. However, using typeof(string) causes either "True" or "False" to appear! I don't want this either. What I want is for no content to be displayed at all. (The cell's value will be communicated to the user by setting CellValuePresenter.Background based on the cell's content.) How may I do this?
Thanks,
Dave
I'll tro to explain my motives for not wanting to display content in a cell. The data type is a bool -- it represents whether an event occurred on an object (corresponding to the row) at a given time (corresponding to the column). It is read-only data. We could have the grid display "True" or "False". That would communicate the information the user needs. However, having a screen full of "True" and "False" is not very user-friendly. What we want to do instead is set CellValuePresenter.Background based on the true / false value. If the event occurred, the cell will be red. Otherwise, it will be white. This makes it *much* easier for the user to find where events occurred (looking for a red block in a mostly-white grid) that looking for a "True" in a screenful of "False".
With this in mind, bool? (i.e. nullable) won't work since null is not a possible value.
Is there any way to restyle / retemplate CellValuePresenter so that it displays nothing?
Hello Dave,
The default value editor for a boolean type is XamCheckEditor. If you change the DataType , then the editor will change accordingly to the new type. As you have set it to string, the value of that cell will be the string representation of a boolean value, which can be True or False.
As you have bound the Field to some data, it will display value - which again are True or False.
I am not sure why you do not want to display any values in a field and why not hide it, but I guess you can make it a nullable boolean "bool?" which will default to null.