6 Answers, 1 is accepted
0
Hello Ben,
Victor
the Telerik team
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.
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.
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
Hello Andrew,
Can you please try doing this in the Loaded event of the page as shown here:
Let me know if you have further questions or need assistance.
Regards,
Deyan
Telerik
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?
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
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.
Todor
Telerik
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.