This is a migrated thread and some comments may be shown as answers.

How can I scroll to conversation view bottom on load?

6 Answers 79 Views
ConversationView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ben
Top achievements
Rank 1
Ben asked on 24 Mar 2013, 09:50 PM
Cannot find any method?

And how can I implement tap & hold on single message event? Thanks.

6 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 26 Mar 2013, 08:58 AM
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.
0
Andrew
Top achievements
Rank 1
answered on 06 Sep 2013, 03:40 PM
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.
0
Deyan
Telerik team
answered on 11 Sep 2013, 08:27 AM
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.
0
Andrew
Top achievements
Rank 1
answered on 12 Sep 2013, 03:18 PM
Thanks, Deyan. That works.
0
Derik
Top achievements
Rank 1
answered on 06 Nov 2013, 07:10 PM
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?
0
Todor
Telerik team
answered on 11 Nov 2013, 02:23 PM
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.
Tags
ConversationView
Asked by
Ben
Top achievements
Rank 1
Answers by
Victor
Telerik team
Andrew
Top achievements
Rank 1
Deyan
Telerik team
Derik
Top achievements
Rank 1
Todor
Telerik team
Share this question
or