Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical alignment of nested label is not working #21

Open
nike61 opened this issue Apr 14, 2021 · 7 comments
Open

Vertical alignment of nested label is not working #21

nike61 opened this issue Apr 14, 2021 · 7 comments

Comments

@nike61
Copy link

nike61 commented Apr 14, 2021

There is no way to create data template with vertically centered label:

<wheelPickerForms:WheelDefinition Width="*" HorizontalOptions="Center" Alignment="Center" IsCircular="True" RowHeight="50">
                        <DataTemplate>
                            <Grid>
                                <Label 
                                    FontSize="24"
                                    TextColor="White" Text="{Binding .}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                            </Grid>
                        </DataTemplate>
                    </wheelPickerForms:WheelDefinition>

The label remains on top. I want this because there is no way to change size of element without DataTemplate

@softlion
Copy link
Owner

That works as expected.
Read your code again and be smarter.

You forced RowHeight="50". ok
The label is centered inside a Grid.
The Grid height is not specified. What do you expect it to be ? Well no, it will be the same height as the label, not the height of the cell.

Add VerticalOption="Fill" to your Grid to obtain what you want.

@nike61
Copy link
Author

nike61 commented Apr 16, 2021

No, the same issue here (I've already tried that):

  <wheelPickerForms:WheelDefinition Width="*" HorizontalOptions="Center" Alignment="Center" IsCircular="True" RowHeight="50">
                        <DataTemplate>
                            <Grid Background="Blue">
                                <Label
                                    Background="yellow"
                                    VerticalOptions="Fill"
                                    FontSize="24"
                                    TextColor="White" Text="{Binding .}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                            </Grid>
                        </DataTemplate>
                    </wheelPickerForms:WheelDefinition>

The blue color is the background of Grid
The yellow color is the background of Label

image

@softlion
Copy link
Owner

Your Grid will take the same height as your Label. So it's expected.

@nike61
Copy link
Author

nike61 commented Apr 17, 2021

But the height is different. Do you see blue and yellow backgrounds?

@softlion
Copy link
Owner

softlion commented Apr 17, 2021

I'm not sure of what I see. The blue is not aligned with the yellow on the right. If that was the same control, their right side would be aligned. At least the yellow won't go farther than the blue.

Could you provide a full repro project ?

@softlion
Copy link
Owner

softlion commented Apr 20, 2021

Works perfectly.

image

code:

<wheelPickerForms:WheelPicker 
                ItemsSourceMulti="{Binding WheelOptions.ItemsSource}"
                SelectedItemsIndex="{Binding WheelOptions.SelectedItemsIndex}" 
                HorizontalOptions="Fill">
    <wheelPickerForms:WheelDefinition Width="Auto" HorizontalOptions="Center" Alignment="Center" RowHeight="50">
        <DataTemplate>
            <Grid BackgroundColor="Red">
                <Label VerticalOptions="Center" Text="{Binding .}" TextColor="Black" HorizontalOptions="Center" FontSize="Body" />
            </Grid>
        </DataTemplate>
    </wheelPickerForms:WheelDefinition>
</wheelPickerForms:WheelPicker>

@softlion
Copy link
Owner

Are you on iOS or Android ?

It seems the issue exist and happens on iOS only.

A workaround is to use

      <wheelPickerForms:WheelDefinition Width="Auto" HorizontalOptions="Center" /> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants