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
close icon

If datatemplate has stacklayout selection and swiping doesnt work

I created a datatemple of sfdatagrid as below. If i use stacklayout within datagrid as datatemplate, selection and swiping doesnt work at all. Is it intended or a bug?

  <sfgrid:GridTemplateColumn.CellTemplate>

              <DataTemplate>
                <Grid BackgroundColor="White" Padding="10" RowSpacing="20">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>

                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="10"></RowDefinition>
                  </Grid.RowDefinitions>

                  <StackLayout Orientation="Vertical" Grid.Row="0" Grid.Column="0" >

                    <Label TextColor="Black"  Text="{Binding level}"/>                
                    <Label  TextColor="Black"   Text="{Binding name}" StyleClass="Header"  />                    

                  </StackLayout>
                  <BoxView Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2"  HorizontalOptions="FillAndExpand" BackgroundColor="Black"></BoxView>                  
                </Grid>
              </DataTemplate>

            </sfgrid:GridTemplateColumn.CellTemplate>

4 Replies

EM Emil December 12, 2016 01:34 AM UTC

Actually error wasnt stacklayout. I figured out later it is caused by BackgroundColor="White" , I dont know what makes the difference but, when I removed it. It cause this error. 


DS Divakar Subramaniam Syncfusion Team December 12, 2016 05:38 AM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. The grid you loaded inside a GridTemplateColumn.CellTemplate will always be placed above the rows in SfDataGrid. Hence, even when you select the row, the background color of the grid will be appeared (in your code White) since the grid is loaded as a child of SfDataGrid. 
If you need to the selection should be appeared, then you should not set background color for the child you loaded in the DataTemplate or you can set the background color as “Transparent”. Please refer the below code snippet. 
<DataTemplate> 
    <Grid BackgroundColor="Transparent" 
          Padding="10" 
          RowSpacing="20"> 
 
        <StackLayout Orientation="Vertical"> 
 
            <Label Text="{Binding OrderID}" TextColor="Black" /> 
            <Label StyleClass="Header" 
                   Text="{Binding CUstomerID}" 
                   TextColor="Black" /> 
 
        </StackLayout> 
    </Grid> 
</DataTemplate> 
   
Also, we have attached a sample for your reference and you can download the same from the below link. 
 
Regards, 
Divakar. 



EM Emil December 12, 2016 10:54 AM UTC

thank you for nice explanation. It works fine now


AN Ashok N Syncfusion Team December 13, 2016 01:12 PM UTC

Hi Emil, 

Thanks for your update. Please let us know if your require further assistance on this. 

Regards, 
Ashok 


Loader.
Live Chat Icon For mobile
Up arrow icon