xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Material DatePicker’s visible height is not fill its own height. #10359

Open jessiezh0320 opened 4 years ago

jessiezh0320 commented 4 years ago

Description

When we put Material DatePicker in a Grid, it's height is not fill the height of the row. Even if we set the VerticalOptions="FillAndExpand" , it doesn't work.

Steps to Reproduce

  1. create a new app and install the Xamarin.Forms.Visual.Material NuGet package, then initialize in each platform project. On iOS, in AppDelegate.cs

    global::Xamarin.Forms.Forms.Init();
    global::Xamarin.Forms.FormsMaterial.Init();

    On Android, r in MainActivity.cs

    global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
    global::Xamarin.Forms.FormsMaterial.Init(this, savedInstanceState); 
  2. add the following code to MainPage.xaml

   <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="MaterialApp1.MainPage">

    <StackLayout Margin="0,300,0,30">
        <Grid >
            <Grid.RowDefinitions >
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="100"></RowDefinition>
                <RowDefinition Height="auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <!--Isim-->
            <Entry Grid.Row="0" Grid.Column="0" Visual="Material" Placeholder="Isim" />

            <!--Countries-->
            <Picker Grid.Row="0" Grid.Column="1" Visual="Material"
                        SelectedIndex="0" SelectedItem="Turkey" Title="This is Picker" >
                <Picker.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>Baboon</x:String>
                        <x:String>Capuchin Monkey</x:String>
                        <x:String>Blue Monkey</x:String>
                        <x:String>Squirrel Monkey</x:String>
                        <x:String>Golden Lion Tamarin</x:String>
                        <x:String>Howler Monkey</x:String>
                        <x:String>Japanese Macaque</x:String>
                    </x:Array>
                </Picker.ItemsSource>
            </Picker>

            <!--Soyisim-->
            <Entry Grid.Row="1" Grid.Column="0" Visual="Material" Placeholder="Soyisim" BackgroundColor="Green" />

            <!--date-->
            <DatePicker Grid.Row="1" Grid.Column="1" Visual="Material"  VerticalOptions="FillAndExpand" BackgroundColor="Green"  />

            <!--button-->
            <StackLayout Grid.Row="2" Grid.ColumnSpan="2">
                <Button  Text="Login" HeightRequest="50" Visual="Material"/>
            </StackLayout>
        </Grid>
    </StackLayout>
</ContentPage>
  1. run and test it in both android and ios platfrom. And when we set property BackgroundColor="Yellow" to the DatePicker , it will like this: image

Expected Behavior

DatePicker’s height could fill the row height just as other control.

Actual Behavior

image

Basic Information

Screenshots

Reproduction Link

Workaround

jsuarezruiz commented 4 years ago

Attached reproduction sample. Issue10359.zip

The behavior on Android seems to be correct, but we haven't the same behavior on iOS:

Captura de pantalla 2020-04-20 a las 13 00 04