ConvertBack 方法什么时候被调用?

发布于 2024-10-24 21:56:33 字数 561 浏览 8 评论 0原文

我知道当即将显示数据时,会调用 Convert() 方法来转换数据,然后显示转换后的数据。

我想知道 ConvertBack() 方法何时被调用?它的目的是什么?

我有一个 DataGrid,其 ItemSource 绑定到某个集合,并且我已为集合中项目的一个属性实现了 IValueConverter。当我创建 IsReadOnly="True" (在 DataGrid 中)时,如果我双击单元格(例如其中 IValueConverter 已实现),然后更改焦点。但是,当我创建 IsReadOnly="False" 时,无论我对 DataGrid 及其单元格做什么,都永远不会调用 ConvertBack 方法。

请解释 DataGrid 单元格和 IValueConverterConvertBack 方法的这种行为。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水染的天色ゝ 2024-10-31 21:56:33

“数据绑定引擎在将值从绑定目标传播到绑定源时调用此方法。”

请参阅 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文