XAML 转换器 ConvertBack
有没有办法直接从 XAML 访问实现 IValueConverter 的转换器的 ConvertBack 方法?
基本情况如下(关系):
Route (1)<->(CN) Training (1)<->(CN) Kilometer
DataContext 设置为 Training。从这里我使用 Convert-Method 来访问我的所有公里
。我还有一个从 Route
到 IList
的转换器,并且 ConvertBack 会查找 Route
中的 Training
。但我似乎无法从 XAML 访问该方法......
Is there a way to access the ConvertBack-Method of a Converter that implements IValueConverter directly from XAML?
The basic situation is the following (relationsships):
Route (1)<->(CN) Training (1)<->(CN) Kilometer
The DataContext is set to a Training. From here I use the Convert-Method to access all my Kilometers
. I also have a Converter from Route
to IList<Training>
and the ConvertBack would lookup the Route
for a Training
. But I seem to not be able to access that Method from XAML…
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您通常不会直接调用
Convert
或ConvertBack
方法。它们仅用于绑定。在将源值分配给绑定目标之前,会调用Convert
方法来转换源值。调用ConvertBack
将值转换回双向绑定中的源。我不确定你想做什么,但转换器似乎不是你最好的选择......也许你应该提供更多关于你想要实现的目标的细节
You usually don't call the
Convert
orConvertBack
methods directly. They are only used in bindings. TheConvert
method is called to convert the source value before it is assigned to the binding target. TheConvertBack
is called to convert the value back to the source in a two-way binding.I'm not sure what you're trying to do, but it doesn't seem like converters are your best option... perhaps you should give more details about what you want to achieve