Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TreeDataGridTextCell changing TextCell.Value
`TreeDataGridTextCell` listens to property changes of `ITextCell.Value` to update its own `Value` property. The setter of `TreeDataGridTextCell.Value` updates `ITextCell.Text` to the string representation of the new value. This is done because the cell can be edited, and `TreeDataGridTextCell.Value` is bound to `TextBox.Text` two-way when the user wants to edit the cell. However, `TextCell<T>.Text` which the setter of `TreeDataGridTextCell.Value` will always set, doesn't respect the read-only status or the editing status of the cell: 1) `TextCell<T>.Value` updates. 2) `TreeDataGridTextCell` reacts and sets `TreeDataGridTextCell.Value` to the string representation of the new value. 3) The setter of `TreeDataGridTextCell.Value` will set `TextCell<T>.Text` to the string representation. 4) The setter of `TextCell<T>.Text` will try to convert the text representation of the new value as the new value... If it weren't for the fact that `RaiseAndSetIfChanged` does what it's supposed to do, which is only raise if changed, this would be a loop that goes on forever. Users will get an exception if `T` of `TextCell<T>` fails to convert: `Convert.ChangeType(value, typeof(T))`. This obviously isn't an issue when `T` is `string` but it does have issues for base types like numbers (localization issues), and custom types will almost always result in an exception.
- Loading branch information