" how to pass specific value to the converter parameter?" Code Answer

4

try using x:static markup extension:

<radiobutton 
        content="female" 
        ischecked="{binding path=gender, 
                    converter={staticresource genderconverter}, 
                    converterparameter={x:static model:gendertype.female}}"/>

or, you could just pass a string and use enum.parse to convert that string to the enum type in the converter:

<radiobutton 
        content="female" 
        ischecked="{binding path=gender, 
                    converter={staticresource genderconverter}, 
                    converterparameter=female}"/>

-

gendertype gender = (gendertype)enum.parse(typeof(gendertype), parameter.tostring());
By Ye Feng on February 8 2022
2

you probably need to include the type then. so either do it inline like this: converterparameter={x:int32 100}.

or write it more verbose:

<label>
     <label.text>
         <binding path="information" converter="{staticresource cutstringconverter}">
             <binding.converterparameter>
                 <x:int32>100</x:int32>
             </binding.converterparameter>
        </binding>
    </label.text>
</label>

or, to be complete, add a static resource to your page (or whatever the container is), like:

<contentpage.resources>
    <x:int32 x:key="inthundred">100</x:int32>
</contentpage.resources>

and reference that: converterparameter={staticresource inthundred}

By etrast81 on July 27 2022

Answers related to “ how to pass specific value to the converter parameter?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.