How to set ConvertParameter in binding in UWP

Viewed 213

I have a scenario where I have to compare the passed enum value through binding in the converter and return visibility for that I want to pass convert parameter in binding expression but here in UWP we don't have x:Static, then how can i do that

I tried these things already

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

it throw error during compilation saying nested x:Bind is not allowed

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

it throws error during runtime saying can't assign binding expression

1 Answers

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

As you mentioned above we can't use x:Static in uwp platform, but we could use StaticResource to replace.

for example

<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}}"
Related