Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass specific value to the converter parameter?

How I send an static value inside ConverterParameter such as a number?

<Label Style="{DynamicResource ListItemDetailTextStyle}" Text="{Binding Information, Converter={StaticResource CutStringConverter}, ConverterParameter={100}}" />
like image 874
mcamara Avatar asked Sep 15 '25 15:09

mcamara


1 Answers

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}

like image 89
Gerald Versluis Avatar answered Sep 18 '25 09:09

Gerald Versluis