[英]WPF: One-way IValueConverter
From what I've been told, I need to create an IValueConverter
to do my custom formatting. 据我
IValueConverter
,我需要创建一个IValueConverter
来进行自定义格式化。 The problem is my formatting is one-way, there is no legitmate ConvertBack
implementation. 问题是我的格式是单向的,没有合法的
ConvertBack
实现。
So, how do I handle one-way IValueConverter
s. 那么,我该如何处理单向
IValueConverter
。 (If it helps, this is for a read-only control.) (如果有帮助,这是一个只读控件。)
All the examples from Microsoft simply throw a NotSupportedException or a NotImplementedException (the former makes more sense) from the ConvertBack
method. 来自Microsoft的所有示例只是从
ConvertBack
方法抛出 NotSupportedException或NotImplementedException (前者更有意义)。
As you say, if the converter is one-way then chances are you'll be using it on a read-only control like TextBlock
, so the ConvertBack
method won't be getting called anyway. 如你所说,如果转换器是单向的,那么你很可能会在像
TextBlock
这样的只读控件上使用它,所以无论如何都不会调用ConvertBack
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.