mobile - MAUI number picker - Stack Overflow

admin2025-04-16  2

I try to implement a number picker looking similar to the standard alarm clock app hour or minute picker. Neither the Picker control nor the CarouselView control are the right choices for a nice looking number picker. And those where the only answers I found so far.

Am I missing any standard control/approach?

The following are extracts form what I tried in my code:

<CarouselView ItemsSource="{Binding SystolicBloodPressureValues}"
                VerticalOptions="CenterAndExpand"
                HorizontalOptions="CenterAndExpand"
                HeightRequest="90"
                Position="{Binding SystolicIndex}">
    
    <CarouselView.ItemsLayout>
        <LinearItemsLayout Orientation="Vertical" />
    </CarouselView.ItemsLayout>
    
    <CarouselView.ItemTemplate>
        <DataTemplate x:DataType="x:Int32">
            <Label Text="{Binding .}"
                    VerticalOptions="Center"
                    HorizontalOptions="CenterAndExpand"
                    FontSize="Medium"
                    Margin="0,0,0,0"
                    HeightRequest="40"/>
        </DataTemplate>
    </CarouselView.ItemTemplate>
    
</CarouselView>


<Picker Title="Systolischen Blutdruck Wert auswählen" 
    ItemsSource="{Binding SystolicBloodPressureValues}" 
    SelectedItem="{Binding Systolic}"
    VerticalOptions="CenterAndExpand"
    HorizontalOptions="CenterAndExpand"/>
转载请注明原文地址:http://www.anycun.com/QandA/1744769605a87369.html