Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Picker on iOS - some Pickers update as items scrolled, some don't

$
0
0

We have two Pickers on a Page:

<Picker
    AutomationId="IdOwnerOfVehiclePicker"
    Margin="0,0,0,10"
    x:Name="OwnerOfVehiclePicker"
    Title="Please select"
    ItemsSource="{Binding OwnerOfVehicleOptions}"
    ItemDisplayBinding ="{Binding Description}"
    SelectedItem ="{Binding SelectedOwnerOfVehicle.Value}"
    Style="{StaticResource PickerStyle}"
    >
    <Picker.Triggers>
        <DataTrigger 
            TargetType="Picker"
            Binding="{Binding SelectedOwnerOfVehicle.IsValid}"
            Value="False">
            <Setter Property="behaviours:LineColorBehavior.ApplyLineColor" Value="True" />
            <Setter Property="behaviours:LineColorBehavior.LineColor" Value="{StaticResource ErrorColor}" />
        </DataTrigger>
        <DataTrigger 
            TargetType="Picker"
            Binding="{Binding SelectedOwnerOfVehicle.IsValid, Converter={StaticResource InverseBoolConverter}}"
            Value="False">
            <Setter Property="behaviours:LineColorBehavior.ApplyLineColor" Value="True" />
            <Setter Property="behaviours:LineColorBehavior.LineColor" Value="{StaticResource BackgroundColor}" />
        </DataTrigger>
    </Picker.Triggers>
    <Picker.Behaviors>
        <behaviours:EventToCommandBehavior
            EventName="SelectedIndexChanged"
            Command="{Binding ValidateSelectedOwnerOfVehicleCommand}" />
    </Picker.Behaviors>
</Picker>
<Label 
    Text="{Binding SelectedOwnerOfVehicle.Errors, Converter={StaticResource FirstValidationErrorConverter}}"
    Style="{StaticResource ValidationMessageStyle}">
</Label>

<Label 
    Margin="0,10,0,0"
    Text="Reason For Cover"
    Style="{StaticResource FormLabel}" />
<Picker
    AutomationId="IdReasonForCoverPicker"
    Margin="0,0,0,10"
    x:Name="ReasonForCoverPicker"
    Title="Please select"
    ItemsSource="{Binding ReasonsForCoverPurchaseOptions}"
    ItemDisplayBinding ="{Binding Description}"
    SelectedItem ="{Binding SelectedReasonForCoverPurchase.Value}"
    Style="{StaticResource PickerStyle}"
    >
    <Picker.Triggers>
        <DataTrigger 
            TargetType="Picker"
            Binding="{Binding SelectedReasonForCoverPurchase.IsValid}"
            Value="False">
            <Setter Property="behaviours:LineColorBehavior.ApplyLineColor" Value="True" />
            <Setter Property="behaviours:LineColorBehavior.LineColor" Value="{StaticResource ErrorColor}" />
        </DataTrigger>
        <DataTrigger 
            TargetType="Picker"
            Binding="{Binding SelectedReasonForCoverPurchase.IsValid, Converter={StaticResource InverseBoolConverter}}"
            Value="False">
            <Setter Property="behaviours:LineColorBehavior.ApplyLineColor" Value="True" />
            <Setter Property="behaviours:LineColorBehavior.LineColor" Value="{StaticResource BackgroundColor}" />
        </DataTrigger>
    </Picker.Triggers>
    <Picker.Behaviors>
        <behaviours:EventToCommandBehavior
            EventName="SelectedIndexChanged"
            Command="{Binding ValidateSelectedReasonForCoverPurchaseCommand}" />
    </Picker.Behaviors>
</Picker>

The OwnerOfVehiclePicker does not update its value as the available value list is scrolled - only when the Done button is tapped.

The ReasonForCover does update its value as the available value list is scrolled - we don't have to tap the Done button.

I cannot see any difference between these two. I don't think the Triggers are relevant - but I've left them in the XAML above, in case someone can spot a side effect.

Can anyone suggest why their behaviour would be different? This is breaking my UITest logic for selecting Picker values.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>