ConvertBack 方法什么时候被调用?
我知道当即将显示数据时,会调用 Convert()
方法来转换数据,然后显示转换后的数据。
我想知道 ConvertBack()
方法何时被调用?它的目的是什么?
我有一个 DataGrid
,其 ItemSource
绑定到某个集合,并且我已为集合中项目的一个属性实现了 IValueConverter
。当我创建 IsReadOnly="True"
(在 DataGrid 中)时,如果我双击单元格(例如其中 IValueConverter
已实现),然后更改焦点。但是,当我创建 IsReadOnly="False"
时,无论我对 DataGrid 及其单元格做什么,都永远不会调用 ConvertBack
方法。
请解释 DataGrid
单元格和 IValueConverter
的 ConvertBack
方法的这种行为。
I know that when data is about to be displayed, Convert()
method is called to convert the data and the converted data is displayed instead.
I'm wondering when ConvertBack()
method gets called? What is its purpose?
I've a DataGrid
whose ItemSource
is binded to some collection, and I've implemented IValueConverter
for one property of items in the collection. When I make IsReadOnly="True"
(in the DataGrid), then ConvertBack
method is called if I double-click on the cell (for which IValueConverter
is implemented) and then change the focus. But when I make IsReadOnly="False"
, then ConvertBack
method is never called, no matter what I do with the DataGrid
and its cells.
Please explain this behavior of DataGrid
cells and ConvertBack
method of IValueConverter
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“数据绑定引擎在将值从绑定目标传播到绑定源时调用此方法。”
请参阅 msdn
您应该发布您的绑定使用 valueconverter 为您的单元格
"The data binding engine calls this method when it propagates a value from the binding target to the binding source."
see msdn
you should post your binding for your cell with the valueconverter