The problem arises only on iOS platform. I have 4 buttons which should be enabled/disabled regarding to the parameter. For this to work I have a converter. When the page is first loaded I can see with debugger that the converter is used 4 timers for each button and it gives the correct boolean value. The problem is that the view is not correctly updated. If the value which defines how many buttons should be enabled is changed again then the view updates correctly. The android platform works without problem. If I change the IsEnabled to IsVisible and don't do any other changes, then the buttons are correctly visible also at the first time. What is the difference between IsEnabled and IsVisible when it comes to update the view?
Code for the Buttons and for the converter:
<Button
Text="String1"
IsEnabled="{Binding NumberOfStrings,
Converter={StaticResource IntToBoolWithParameter},
ConverterParameter=1}"
Command="{Binding StringTapped}"
CommandParameter="1" />
<Button
Text="String2"
IsEnabled="{Binding NumberOfStrings,
Converter={StaticResource IntToBoolWithParameter},
ConverterParameter=2}"
Command="{Binding StringTapped}"
CommandParameter="2" />
<Button
Text="String3"
IsEnabled="{Binding NumberOfStrings,
Converter={StaticResource IntToBoolWithParameter},
ConverterParameter=3}"
Command="{Binding StringTapped}"
CommandParameter="3" />
<Button
Text="String4"
IsEnabled="{Binding NumberOfStrings,
Converter={StaticResource IntToBoolWithParameter},
ConverterParameter=4}"
Command="{Binding StringTapped}"
CommandParameter="4" />
public class IntToBoolWithParameterConverter : IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
string strParam = parameter as string;
int reference = 0;
if (!String.IsNullOrEmpty(strParam))
{
Int32.TryParse(strParam, out reference);
}
bool answer = false;
if (!value.Equals(null))
answer = reference <= (int)value;
System.Diagnostics.Debug.WriteLine(answer + " " + parameter);
return answer;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
return 0;
}
}