本文介绍了WPF数据绑定和级联转换器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有可能使用WPF绑定时级联转换器。
例如像

i wonder if it is possible to cascade converters when using wpf databinding.e.g. something like

<SomeControl Visibility="{Binding Path=SomeProperty, Converter={StaticResource firstConverter}, Converter={StaticResource secondConverter}}"/>

是它在所有可能的或我要创造,结合转换器A和B的功能的自定义转换器?

is it possible at all or do i have to create a custom converter that combines the functionality of converter A and B?

推荐答案

您可以尝试使用 MultiBinding ,然后结合两次同出一源,但对单一绑定不同的转换。是这样的:

You could try to use a MultiBinding, and bind twice to the same source, but with different converts on the single bindings. Something like:

<SomeControl>
    <SomeControl.Visibility>
        <MultiBinding Converter="{StaticResource combiningConverter}">
            <Binding Path="SomeProperty" Converter="{StaticResource firstConverter}"/>
            <Binding Path="SomeProperty" Converter="{StaticResource secondConverter}"/>
        </MultiBinding>
    </SomeControl.Visibility>
</SomeControl>

然后在 combiningConverter 的'你把从两个绑定来的值相结合的逻辑。

Then in 'combiningConverter' you put the logic to combine the values coming from the two bindings.

这篇关于WPF数据绑定和级联转换器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:50