1

In my Xamarin xaml file I have a ProgressBar, where I need to compute Progress (Value/Maximum). So I wrote my Convertor, but I am not able to pass the Maximum to the Convertor.

I tried to use ConverterParameter, but it does not support bindings...

<ProgressBar Progress="{Binding Progress.Value, 
    Converter={StaticResource Convertor}, ConverterParameter=??}" />

Am I doing something wrong or is there any workaround?

1 Answer 1

2

You could pass a reference directly into your converter if it's defined in xaml of whatever class/ViewModel that has all the values you need to calculate progress.

<ProgressBar x:Name="_progressBar" Progress="{Binding Progress.Value,
    Converter={StaticResource Convertor}, ConverterParameter={x:Reference _progressBar}}" />

or you could just pass in the value directly in xaml or as a static value defined in a static class from elsewhere in your app, which is of course if you know what the value will be ahead of time.

, ConverterParameter=1}" or
, ConverterParameter={x:Static local:DefaultValues.MaxValue}}"

However, it does sound like you could calculate Progress in your ViewModel on property changed before setting Progress.Value/Progress.MaxValue property, and then you wouldn't even need a converter.

2
  • I have the Maximum property in the Progress class and the Maximum property changes in the runtime. Commented Oct 17, 2018 at 13:44
  • Maximum is always 1, if you need to change it dynamically you should just re-calculate the Progress on your 'MaximumProperty` change
    – Ranga
    Commented Oct 18, 2018 at 9:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.