How can I scroll to conversation view bottom on load?

7 posts, 0 answers
  1. Ben
    Ben avatar
    5 posts
    Member since:
    Feb 2013

    Posted 24 Mar 2013 Link to this post

    Cannot find any method?

    And how can I implement tap & hold on single message event? Thanks.
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 26 Mar 2013 Link to this post

    Hello Ben,

    RadConversationView has a BringIntoView() method. You just have to pass the data item that needs to be visualized the the conversation view will scroll to it.

    In order to implement tap and hold for a data item you can implement your own custom control for use in the ItemTemplate of the list box. Then you can implement any logic you want when any event is triggered.

    Regards,
    Victor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Andrew
    Andrew avatar
    5 posts
    Member since:
    Apr 2011

    Posted 06 Sep 2013 Link to this post

    This method doesn't work for me. I'm trying code such as this:

    if (conversation.MessageViewModels.Count > 0) {
     this.conversationView.BringIntoView(conversation.MessageViewModels[conversation.MessageViewModels.Count - 1]);
    }

    But no scrolling happens. I have this code in my OnNavigatedTo event handler, which is also where I set the DataContext for the page (and ItemsSource gets set in the XAML based on that). I tried "await Task.Yield();" between setting DataContext and the BringIntoView call so that data binding has a chance to happen, and stepping through the code I see that the conversation view has been rendered, but it still doesn't scroll to the last message.
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 11 Sep 2013 Link to this post

    Hello Andrew,

    Can you please try doing this in the Loaded event of the page as shown here:

    void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                this.conversationView.ItemsSource = source;
     
                this.Dispatcher.BeginInvoke(() =>
                    {
                        this.conversationView.BringIntoView((this.conversationView.ItemsSource as ObservableCollection<CustomMessage>)[(this.conversationView.ItemsSource as ObservableCollection<CustomMessage>).Count - 1]);
                    });
            }

    Let me know if you have further questions or need assistance.

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Andrew
    Andrew avatar
    5 posts
    Member since:
    Apr 2011

    Posted 12 Sep 2013 Link to this post

    Thanks, Deyan. That works.
  7. Derik
    Derik avatar
    4 posts
    Member since:
    Oct 2010

    Posted 06 Nov 2013 Link to this post

    I am also trying to get this to work, but having NO luck.  In my case i am not able to use the Loaded event to do this as my data comes back async web service call.  My code is am trying is 

                Dispatcher.BeginInvoke(() =>
                {
                    var chatMessageViewModels = ConversationView.ItemsSource as ObservableCollection<ChatMessageViewModel>;
                    if (chatMessageViewModels != null)
                        ConversationView.BringIntoView(chatMessageViewModels[chatMessageViewModels.Count - 1]);
                });

    If i manually trigger this EXACT code via some sort of UI tap event it works as expected.

    Help?
  8. Todor
    Admin
    Todor avatar
    778 posts

    Posted 11 Nov 2013 Link to this post

    Hi Derik,

    Thank you for writing.

    In order to bring an item into view you need to make sure that the items are loaded. Depending on the web service that you use, there may be a different way to determine when the items are loaded. For example, an event that fires when the data is loaded or a method that can be awaited. When you know the data is loaded you can execute the code you posted without the need of using a tap event.

    I hope this information helps.

     

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner