We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Is it possible to display SfDataGrid after other Xamarin's element ?

I'm trying to display a title with some informations and then display my DataGrid, the problem is that the datagrid don't appear on my page.
Here's my code : 

<?xml version="1.0" encoding="utf-8" ?>
<controls:KerhisContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                            BindingContext="{Binding MouvementAnimaux, Source={StaticResource Locator}}"
                            Title="Mouvements Animaux">
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="1*"/>
          <ColumnDefinition Width="1*"/>
          <ColumnDefinition Width="1*"/>
          <ColumnDefinition Width="1*"/>
          <ColumnDefinition Width="1*"/>
          <ColumnDefinition Width="1*"/>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
        <Image Source="salle.png" Grid.Column="0" Grid.Row="0"/>
        <Label Text="Nom de la salle : " FontSize="Medium" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="1" Grid.Row="0"/>
        <Label Text="{Binding Salle.LibelleSalle}" FontSize="Medium" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="2" Grid.Row="0"/>
        <Label Text="Batiment : " FontSize="Medium" HorizontalOptions="End" VerticalOptions="Center" Grid.Column="3" Grid.Row="0"/>
        <Label Text="{Binding Salle.Batiment.LibelleBatiment}" FontSize="Medium" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="4" Grid.Row="0"/>
        <Label Text="Site : " FontSize="Medium" HorizontalOptions="End" VerticalOptions="Center" Grid.Column="5" Grid.Row="0"/>
        <Label Text="{Binding Salle.Site.LibelleSite}" FontSize="Medium" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="6" Grid.Row="0"/>

        <Image Source="cochon.png" Grid.Column="0" Grid.Row="1"/>
        <Label Text="{Binding NombreAnimaux}" FontSize="Medium" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/>

      <cr:KerhisDataGrid AutoGenerateColumns="False"
                         ItemsSource="{Binding ListeMouvementAnimaux}"

        <syncfusion:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns" >
          <syncfusion:GridTextColumn HeaderText="Date"
          <syncfusion:GridTextColumn HeaderText="Effectif J-1"

          <syncfusion:GridTextColumn HeaderText="Effectif J-J"

          <syncfusion:GridTextColumn HeaderText="Différence"

          <syncfusion:GridTextColumn HeaderText="Qualification"

          <syncfusion:GridTextColumn HeaderText="N° Bon Uniporc associé"

          <syncfusion:GridTextColumn HeaderText="Commentaire"



If anyone know what's the problem, please help me
Thanks !

5 Replies

HN Harikrishnan N Syncfusion Team July 29, 2016 12:11 PM UTC

Hi Yasahbi,  

Thank you for using Syncfusion Products.  

We have analyzed your query and you can get this fixed simply by setting the SfDataGrid.VerticalOptions as “FillAndExpand”. Please refer the below code example for the same.  

<?xml version="1.0" encoding="utf-8" ?>   
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"   
             xmlns:local ="clr-namespace:StackLayoutSample;assembly=StackLayoutSample"   
    <local:ViewModel x:Name="viewModel" />   
      <StackLayout VerticalOptions="FillAndExpand">   
        <Label Text="Stack Layout Demo" FontSize="20" HeightRequest="50"HorizontalTextAlignment="Center"/>   
        <syncfusion:SfDataGrid x:Name="dataGrid"   
                               ItemsSource="{Binding ItemList}"   
                               SelectionMode="SingleDeselect" />   
We have also published a KB for the same and you can refer it from the following link. 

When you load a custom view inside a StackLayout, the height to render the custom view will be passed as zero by the StackLayout which results in the above issue. Hence to get this fixed you have to set the LayoutOptions for the custom view.


YA Yasahbi July 29, 2016 12:40 PM UTC

Hi Harikrishnan !

I found the answer just before you replied me and i was about to write it here.
But thanks for your time anyway ! :)

AN Ashok N Syncfusion Team August 1, 2016 05:21 AM UTC

Hi Yasahbi, 
Thanks for your update. Please let us know if you require further assistance on this.  

KI Kirill February 28, 2019 10:00 AM UTC

Hi, i have this problem, although I set the values ​​to FillAndExpand

SP Subburaj Pandian Veluchamy Syncfusion Team March 1, 2019 09:00 AM UTC

Hi Kirill, 
We have prepared sample based on your requirement “Loading Xamarin element along with the SfDataGrid” in Xamarin.Forms. In the sample, we have loaded SearchBar and DataGrid in the Stack layout, it has rendered as expected without any issue.  Please find the sample by the following link.  
Sample link: DataGridSample 
Kindly check the sample, If the sample doesn’t meet your requirement, kindly modify the sample based on your scenario and revert us back with more details. It will be helpful for us to check on it and provide you the solution.  
Subburaj Pandian V  

Live Chat Icon For mobile
Up arrow icon