如何在 UWP 绑定中设置 ConvertParameter

How to set ConvertParameter in binding in UWP

我有一个场景,我必须比较通过转换器中的绑定传递的枚举值和 return 我想在绑定表达式中传递转换参数的可见性,但在 UWP 中我们没有x:Static,那我该怎么做呢

我已经尝试过这些东西了

Visibility="{x:Bind   vm.ControlState, 
                        Mode=OneWay,
                        Converter={StaticResource enumToVisibilityConverter}, 
                        ConverterParameter={x:Bind enums:TextControlState.Controls}}"

它在编译期间抛出错误说嵌套 x:Bind 是不允许的

Visibility="{Binding   ControlState, 
            Mode=OneWay,
            Converter={StaticResource enumToVisibilityConverter}, 
            ConverterParameter={x:Bind enums:TextControlState.Controls}}"

它在运行时抛出错误,提示无法分配绑定表达式

but here in UWP we don't have x:Static, then how can i do that

正如你上面提到的,我们不能在uwp平台上使用x:Static,但是我们可以用StaticResource来代替。

例如

<Page.Resources>
    <local:TextControlState x:Key="ConState">Controls</local:TextControlState>
</Page.Resources>



Visibility="{x:Bind  vm.ControlState, 
                    Mode=OneWay,
                    Converter={StaticResource enumToVisibilityConverter}, 
                    ConverterParameter={StaticResource ConState}}"