Binding by parameter using LINQ

RianDutraRianDutra USMember ✭✭
edited January 2017 in Xamarin.Forms

I have these classes:
https://codepaste.net/ciadta

In my Page.xaml, I'd like to bind only messages from a especific conversation.
For example, when user access a conversation with "To" = 456, only messages from this conversation would be displayed.

So, I can't use simply {Binding Conversation}, because it has the attribute "To" and "Messages", and it wouldn't bind its messages.

Theorically, I'd like to user something like this:
var currentConversation = Conversations.Single(c => c.To == SelectedUser.Id.ToString());
CurrentMessages = new ObservableCollection<Message>(currentConversation.Messages);

But it's not the best way, because new messages will be load in realtime, thus it'd be needed to upated CurrentMessages everytime Conversation receive new messages from server.

Can anyone help me?
Thank you.

Sign In or Register to comment.