Created
December 15, 2017 13:59
-
-
Save juucustodio/5f0fca96480f460fe22a454e05c75b3c to your computer and use it in GitHub Desktop.
Example of Chat in Xamarin.Forms applications - http://julianocustodio.com/chat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DemoChat.CustomCells; | |
using DemoChat.Models; | |
using Xamarin.Forms; | |
namespace DemoChat | |
{ | |
public class SelectorDataTemplate : DataTemplateSelector | |
{ | |
private readonly DataTemplate textInDataTemplate; | |
private readonly DataTemplate textOutDataTemplate; | |
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | |
{ | |
var messageVm = item as Message; | |
if (messageVm == null) | |
return null; | |
return messageVm.IsTextIn ? this.textInDataTemplate : this.textOutDataTemplate; | |
} | |
public SelectorDataTemplate() | |
{ | |
this.textInDataTemplate = new DataTemplate(typeof(TextInViewCell)); | |
this.textOutDataTemplate = new DataTemplate(typeof(TextOutViewCell)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment