Last active
December 15, 2017 15:49
-
-
Save juucustodio/33146d79cdcbbd48369449d946902705 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 System; | |
using System.Globalization; | |
using System.Windows.Input; | |
using DemoChat.Models; | |
using MvvmHelpers; | |
using Xamarin.Forms; | |
namespace DemoChat.ViewModels | |
{ | |
public class MainPageViewModel : BaseViewModel | |
{ | |
public ObservableRangeCollection<Message> ListMessages { get; } | |
public ICommand SendCommand { get; set; } | |
public MainPageViewModel() | |
{ | |
ListMessages = new ObservableRangeCollection<Message>(); | |
SendCommand = new Command(() => | |
{ | |
if (!String.IsNullOrWhiteSpace(OutText)) | |
{ | |
var message = new Message | |
{ | |
Text = OutText, | |
IsTextIn = false, | |
MessageDateTime = DateTime.Now | |
}; | |
ListMessages.Add(message); | |
OutText = ""; | |
} | |
}); | |
} | |
public string OutText | |
{ | |
get { return _outText; } | |
set { SetProperty(ref _outText, value); } | |
} | |
string _outText = string.Empty; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment