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.
Unfortunately, activation email could not send to your email. Please try again.

Scroll to last item of SfListView

Thread ID:

Created:

Updated:

Platform:

Replies:

128397 Jan 18,2017 05:28 PM Nov 15,2017 10:54 PM Xamarin.Forms 11
loading
Tags: SfListView
Luke
Asked On January 18, 2017 05:28 PM

Hello,

I search for a equivalent method as the Xamarin.Forms ListView.ScrollTo(Object item, ScrollToPosition position, Boolean animated).

ListView.ScrollTo - Xamarin Documentation

I want to scroll to the last item of SfListView. Is there any way to do this?

Best regards
Luke

Dinesh Babu Yadav [Syncfusion]
Replied On January 18, 2017 10:47 PM

Hi Luke,   
   
Thank you for using Syncfusion products.   
   
You can achieve your requirement “Adjust scroll position programmatically in SfListView” by using ScrollToRowIndex method. The following code example illustrates to position the scroll viewer while initializing the SfListView.    
    
Code example[C#]:    
    
listView.Loaded += ListView_Loaded;    
    
private void ListView_Loaded(object sender, ListViewLoadedEventArgs e)    
{    
    (listView.LayoutManager as LinearLayout).ScrollToRowIndex(ViewModel.contactsinfo.Count);    
}    
    
    
For your reference, we have attached the sample also. Please find the sample link below,    
 
Regards,    
Dinesh Babu Yadav  


Luke
Replied On January 19, 2017 03:59 PM

Hi,

thank you for the fast answer. I try it.

Regards
Luke

Dinesh Babu Yadav [Syncfusion]
Replied On January 19, 2017 11:39 PM

Hi Luke,  
  
Thanks for the update.  
  
We will wait to hear from you.  
  
Regards,  
Dinesh Babu Yadav 


Dirk Prodi
Replied On April 12, 2017 08:18 AM

Hi Luke,   
   
Thank you for using Syncfusion products.   
   
You can achieve your requirement “Adjust scroll position programmatically in SfListView” by using ScrollToRowIndex method. The following code example illustrates to position the scroll viewer while initializing the SfListView.    
    
Code example[C#]:    
    
listView.Loaded += ListView_Loaded;    
    
private void ListView_Loaded(object sender, ListViewLoadedEventArgs e)    
{    
    (listView.LayoutManager as LinearLayout).ScrollToRowIndex(ViewModel.contactsinfo.Count);    
}    
    
    
For your reference, we have attached the sample also. Please find the sample link below,    
 
Regards,    
Dinesh Babu Yadav  


(listView.LayoutManager as LinearLayout).ScrollToRowIndex

Hello,

How am I able to get the current RowIndex which is visible? For our use case we want to scroll by e.g. 10 items

Best regards,
Daniel


Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On April 13, 2017 08:59 AM

Hi Daniel, 
  
You can achieve your requirement “Visible index in the view in SfListView” by using theScrollRows.Changed event. The following code illustrates how to get the First visible index and Last visible index for the ListView items which are currently in the View whenever scroll. 
  
Code example:[C#] 
 
    VisualContainer visualContainer = listView.GetType().GetRuntimeProperties().First(p => p.Name == "VisualContainer").GetValue(listView) as VisualContainer; 
    scrollRows = visualContainer.GetType().GetRuntimeProperties().First(p => p.Name =="ScrollRows").GetValue(visualContainer) as ScrollAxisBase; 
    scrollRows.Changed += ScrollRows_Changed; 
  
private void ScrollRows_Changed(object sender, ScrollChangedEventArgs e) 
{ 
  var firstIndex= scrollRows.ScrollLineIndex; 
  var lastindex = scrollRows.LastBodyVisibleLineIndex; 
} 
  
For your reference we have attached the sample also. Please find the sample link below. 
  
  
Regards, 
G.Muthu Kumaran. 


Bharathi
Replied On November 7, 2017 03:04 AM

Hi, i am using SflistView for horizontal listview.but my problem is, i want to show items with shadow as uploaded file.i used frame inside listview but could not get the proper result as i expected.is there any possible to reach this ? 


Attachment: shadow_d20d7ddf.zip

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On November 8, 2017 08:39 AM

Hi Bharathi, 
 
We have checked with the reported query and referred the attached screenshot from our side. You can achieve your requirement by loading the SfListView inside a Frame with its HasShadow property value set as ‘True’ as like below code example. 
 
Code example[XAML]: 
<ContentPage> 
    <Grid RowSpacing="0" BackgroundColor="#E5E4E2"> 
        <Grid.RowDefinitions> 
          <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions> 
         
        <Frame HasShadow="True" Margin="8,8,8,8" Padding="0,0,0,0"> 
        <sync:SfListView x:Name="listView" HeightRequest="220" ItemSize="100" 
                         SelectionMode="None" 
                         Orientation="Horizontal" 
                         ItemsSource="{Binding PizzaInfo}"> 
          <sync:SfListView.ItemTemplate> 
            <DataTemplate> 
              <Frame BackgroundColor="#ff8e02" Padding="2"> 
                                 
               <Grid RowSpacing="0" HorizontalOptions="Fill" VerticalOptions="Fill"> 
                  <Grid.RowDefinitions> 
                    <RowDefinition Height="*" /> 
                    <RowDefinition Height="20" /> 
                  </Grid.RowDefinitions> 
                  <Image Source="{Binding PizzaImage}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" /> 
                  <Label Grid.Row="1" Text="{Binding PizzaName}" 
                         LineBreakMode="WordWrap" 
                         HorizontalTextAlignment="Center" 
                         VerticalTextAlignment="Center" 
                         TextColor="#8f0100" 
                         FontAttributes="Bold"/> 
                </Grid> 
              </Frame> 
            </DataTemplate> 
          </sync:SfListView.ItemTemplate> 
        </sync:SfListView> 
      </Frame> 
    </Grid> 
</ContentPage> 
 
For your reference, we have attached the sample and screenshot in the below link. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 


Bharathi
Replied On November 9, 2017 03:40 AM

Hi Muthu,

 I have used 'Frame' and its property HasShadow already.but i did not get the result.please find the attached file.its showing as something like boarder ,not like shadow.please could u check my previous attached file.i want like that.

 


Attachment: shadowFile_6c048b14.zip

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On November 10, 2017 07:19 AM

Hi Bharathi, 
 
We have checked with the attached image. You can achieve your requirement by setting padding for Frame and loading it inside a Grid. You can choose the desired BackgroundColor for Grid which will be applied as border color for the Frame when applying padding for all sides. For your assistance, we have attached the sample link with the screenshot below. 
 
 
Screenshot: 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 


Bharathi
Replied On November 15, 2017 07:50 AM

Hi Muthu,

Thanks for your efforts.and it is useful.

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On November 15, 2017 10:54 PM

Hi Bharathi, 
 
Thanks for the update. 
 
Regards, 
G.Muthu Kumaran. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;